What's TypeError: 'int' object is not iterable?


#1


#2

we can’t loop over integers. That will give a TypeError.

Why would you want a loop?


#3

Right…Thx!!!


#4

Did that solve your problem?


#5

why can the loop b used in this context?


#6

because my_list is type list:

print type(my_list)

while gold was of type integer:

print type(inventory['gold'])

loop works fine on string and list, just not on integer


#7

got it. thank you so much