It's Dangerous To Go Alone! Take This


#1

Here is my code, which isn't working.

inventory = {
'gold' : 500,
'pouch' : ['flint', 'twine', 'gemstone'], # Assigned a new list to 'pouch' key
'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']
}

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['pocket']= ['seashell', 'strange berry', 'lint']
inventory['backpack'].sort()
inventory['backpack']=['xylophone', 'bedroll', 'bread loaf']
inventory['gold']=500 + 50
print inventory


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

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


I'm confused because it looks to me like I have called the sort function for backpack. Can someone please explain what I'm doing wrong?

Thank you!


#2

You had sorted the list successfully. But

inventory['backpack']=['xylophone', 'bedroll', 'bread loaf']

This line reordered the list. The list is not in alphabetical order.


#3

Solved-- thank you! :slight_smile:


#4

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