It's dangerous to go alone


So doing this exercise and already past it by changing my code but curious why my initial idea doesn't work.

The assignment is to:

Add 50 to the number stored under the 'gold' key

When i use the .append method it doesnt accept it and gives me

File "python", line 17
inventory['gold'].append(+= 50)
SyntaxError: invalid syntax

why can't I do it this way?

inventory = {
    'gold' : 500,
    'pouch' : ['flint', 'twine', 'gemstone'], # Assigned a new list to 'pouch' key
    'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']

inventory['gold'].append( += 50)


because .append() is a method to append an item to a list, 500 is a integer.


Ok, thanks for the explaination


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