Why is this code not working


for the last part in dictionary ex.11,

for number in inventory['gold']:

it shows error 'int' object is not iterable
what does this error means


Hi @vdrago,

Your code attempts to iterate through inventory['gold'], which should be an int. An int is not iterable.

Instead, you need to increase the value of inventory['gold'] by 50, either like this ...

inventory['gold'] = inventory['gold'] + 50

... or like this ...

inventory['gold'] += 50


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.