Invalid Syntax error in Dictionaries and Lists


#1



https://www.codecademy.com/courses/python-beginner-en-pwmb1/2/5?curriculum_id=4f89dab3d788890003000096#


File "python", line 15
inventory['gold'] : 550
^
SyntaxError: invalid syntax


The question asked me to add 50 to the number stored under the gold key. However I get an Invalid Syntax error when I try to do the same . Can someone please correct my code and explain as to where I went 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'
inventory['pouch'].sort() 
inventory['backpack'].sort()
inventory['backpack'].remover('dagger')
inventory['gold'] : 550


#2

A typo that will raise an exception.

Obvious error if you've been around. The value at present is 500. How would you go about increasing it to 550?


#3

That's kind of what I'm unsure about. I was asked to increase the default value by 50


#4

Hey thanks man. I just figured out my mistakes. Silly me!


#5

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