It's Dangerous to go alone! Take This; What is wrong with my code?!?!


I have no idea what is wrong with my code. I have waited at least a month before resorting to the Q&A forums. Could someone tell me what is wrong?

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

# Adding a key 'burlap bag' and assigning a list to it
inventory['burlap bag'] = ['apple', 'small ruby', 'three-toed sloth']

# Sorting the list found under the key 'pouch'

# Your code here
inventory['gold'] += 50

The error reads:
File "python", line 5
'pocket' : ['seashell', 'strange berry', 'lint']
SyntaxError: invalid syntax
indent preformatted text by 4 spaces

Also, here is the message that pops up when I click 'save and submit':
Oops, try again. Did you accidentally delete the inventory dictionary? Click Reset Code to get back to the original code.


Missing comma after this member.


You have to add the 'pocket' key like this

# Adding a key 'burlap bag' and assigning a list to it
inventory['burlap bag'] = ['apple', 'small ruby', 'three-toed sloth']

inventory['pocket'] = ['seashell','strange berry', 'lint']

at least that worked for me.


IT WORKED!!! Thank you so much!


you helped me I helped you lol np


Oh. i stop on this +=50 :open_mouth:


LOL :joy:Thanks so much for the help!


That inventory['gold'] += 50 was a hit for me too.:slightly_smiling:


i stopped on the gold part, was trying to o it with .append, gawd that was stupid


The += 50 thing helped me, too. Is there another way to add ints? I tried ".add" and ".sum" and even ".append".


i dont think there is any other way


When a value is a member element of a data structure, we have to access the element to modify the value.


looks like a reference, but to the compiler, it is a value, 500. To change that value, we operate on it directly:

inventory['gold'] += 50

Now the value is 550.

The only other way to change it is to assign a new value, but that wipes out the old one. We might not wish to do that in most cases. This example adjusts the value, in place.