Invalid Syntax error in Dictionaries and Lists


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['gold'] : 550


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?


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


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


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