Dictionary Problems


#1


Error "Oops, try again. Did you accidentally delete the inventory dictionary? Click Reset Code to get back to the original code."

I think it only triggers the error when I add the list Pocket to inventory


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;

Thanks to anyone that helps!


#2

the problem is here:

'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']

a , is missing at the end to separate key+value pairs


#3

You just need a comma right there:

because you added pocket to the dictionary. Next time read the error message and try to determine what's wrong. :slight_smile:


#4

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