Python lists and Dictionaries


#1



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


Oops, try again. Did you remember to sort the list at inventory["backpack"]?


What is wrong with this piece of code?


inventory = {
    'gold' : 500,
    'pouch' : ['flint', 'twine', 'gemstone'], 
    'backpack' : ['xylophone','dagger', 'bedroll','breadloaf']
}

inventory['burlap bag'] = ['apple', 'small ruby', 'three-toed sloth']
inventory['pouch'].sort() 
# Your code here

inventory['pocket'] = ['seashell','strange berry','lint']
inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold']+=50


#2

here:

'backpack' : ['xylophone','dagger', 'bedroll','breadloaf']

bread loaf should be two words, not one.


#3

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