"'int' object is not iterable" iterating over a dict

mmiikkee13 mmiikkee13 at gmail.com
Mon Oct 6 02:11:28 CEST 2008


>>> a_list = range(37)
>>> list_as_dict = dict(zip(range(len(a_list)), [str(i) for i in a_list]))
>>> for k, v in list_as_dict:
...     print k, v
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable

What 'int' object is this referring to? I'm iterating over a dict, not
an int.



More information about the Python-list mailing list