Why is this code not working


#1

for the last part in dictionary ex.11,

for number in inventory['gold']:
number=number+50

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


#2

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

#3

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