The following code, simple and clear enough, produces an error when compiled: import string import collections #create dictionary with alphabets as keys, and empty values list = [
Solution 1:
you overwrite the internal list, being the name of a type, with your list = ['aema', 'airplane', 'amend'] above. Rename your list to e.g. keys or keylist and all will be fine.
So replace
list = ['aema', 'airplane', 'amend']
with
keys = ['aema', 'airplane', 'amend']
and
forxin list:
with
forx in keys:
Share
Post a Comment
for "Python Collections.defaultdict() Compile Error"
Post a Comment for "Python Collections.defaultdict() Compile Error"