The following works as expected:
d = [(1,2), (3,4)]
for k,v in d:
print "%s - %s" % (str(k), str(v))
But this fails:
d = collections.defaultdict(int)
d[1] = 2
d[3] = 4
for k,v in d:
print "%s - %s" % (str(k), str(v))
With:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
Why? How can i fix it?