If aldurstengd_ororka
is a dictionary, then this expression:
aldurstengd_ororka([age])
is an error. Perhaps you meant something like:
aldurstengd_ororka[(age)]
EDIT: The error you were seeing is quite interesting, I did reproduce it with this snippet:
for age in aldurstengd_ororka.keys():
print 'age:', age
for item in age:
print item
The output of the code is:
age: (32, 33)
32
33
age: (36, 37)
36
37
age: (51, 52, 53, 54, 55)
51
52
53
54
55
age: (61, 62, 63, 64, 65, 66)
61
62
63
64
65
66
age: (30, 31)
30
31
age: 25
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/ma/mak/Documents/t.py in <module>()
3 for age in aldurstengd_ororka.keys():
4 print 'age:', age
----> 5 for item in age:
6 print item
7
TypeError: 'int' object is not iterable
So, what happens is Python 'unpacks' a tuple of 1 element when assigning it to the age variable. So age instead of (25)
, as you would expect, is just 25
... It's a bit strange. A workaround would be to do something like:
for age in aldurstengd_ororka.keys():
# if not tuple, make it a tuple:
if not type(age) == type( (0,1) ): age = (age,)
print 'age:', age
for item in age:
print item