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

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

Why would you want a loop?


Did that solve your problem?

why can the loop b used in this context?

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

got it. thank you so much