I have a dictionary like the following in python 3:
ss = {'a':'2', 'b','3'}
I want to convert all he values to int using map function, and I wrote something like this:
list(map(lambda key,val: int(val), ss.items())))
but the python complains:
TypeError: () missing 1 required positional argument: 'val'
My question is how can I write a lambda function with two inputs (E.g. key and val)
(key, val).ss.values()?itertools.starmapinstead of plainmapas it unpacks the arguments for us(but only if you're using both keys and values, otherwise it's unnecessary as BrenBarn pointed out). In Python 2 it was possible using simple tuple argument unpacking:lambda (key, val): int(val).{k: int(v) for k, v in ss.items()}Or if you want to modify the dict inplace:for k, v in ss.items(): ss[k] = int(v)values = map(int, ss.values())