I'm not seeing what's wrong with my code, would somebody help me out with this please?


#1



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


File "python", line 5
'pocket' : ['seashell', 'strange berry', 'lint']
^
SyntaxError: invalid syntax


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() 

# Your code here
inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold'] += 50


#2

You have to use commas to separate key : value pairs:

inventory = {
    'gold' : 500,
    'pouch' : ['flint', 'twine', 'gemstone'],
    'backpack' : ['xylophone','dagger', 'bedroll','bread loaf'], # <-- added comma
    'pocket' : ['seashell', 'strange berry', 'lint']
}

#3

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