I\'m creating a function that consolidates a couple of lists into a string and am encountering the below error.
Traceback (most recent call last):
File \"Tradi
If you are using Python 2, then either map
or dict
is bound to None
. Check the rest of your code for assignments to either name.
Note that instead of map(None, iterable1, iterable2)
you can use zip(iterable1, iterable2)
to get the same output.
If you are using Python 3, then the map()
method does not support None
as a first argument:
>>> list(map(None, [1], [2]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
and you certainly want to use zip()
there:
defsTwo = dict(zip(letters, defsOne))
If you're using Python 3 then first argument to map is ought to be a function. You're passing None
so it tries to call a None
. This is a different than in Python 2, when None
was treated like an identity function (Python's 2 map).
For Python 2 case see Martijn Pieters's answer.
#Use Of Zip() function
#Generate tuple
x=zip( range(5), range(1,20,2) ) print("Tuple : ",tuple(x))
#Generate List
x=zip( range(5), range(1,20,2) ) print("List : ",list(x))
#Generate dictonary
x=zip( range(5), range(1,20,2) ) print("Dictonary : ",dict(x))