14/14 Its dangerous to go alone


#1

I have the following code but it is bringing up an error message:

Did you remember to sort the list at inventory["backpack"]?

Can anyone help. I am not quite sure what I have missed out as thought I had already sorted the list. See below for my code. Thanks

inventory = {
"gold": 500,
"pouch": ['flint','twine','gemstone'],
"backpack": ['xylophone','dagger', 'breadroll','bread loaf'],
"pocket": ['seashell', 'strange berry', 'lint', 'key']
}

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

Sorting the list found under the key backpack

inventory['backpack'].sort()
inventory['backpack'].remove("dagger")

inventory['gold'] = inventory['gold'] + 50

print inventory["backpack"]
print inventory


#2

@pymaster23365: It seems your code is incorrect, unless there's something I didn't notice.
Try refreshing the page and executing again, if it still doesn't work, get your code and compile with another program, such as repl.it


#3

Still struggling with this. Tried refreshing it. Tried compiling it and running it in another program and could not get it to work. Will try repl.it now and then come back here again if it doesnt work. Cheers

inventory = {
'gold': 500,
'pouch': ['flint','twine','gemstone'],
'backpack': ['dagger', 'bread loaf','breadroll','xylophone'],
'pocket': ['seashell', 'strange berry', 'lint', 'key']
}

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 and under backpack

inventory['pouch'].sort()
inventory['backpack'].sort()
inventory['backpack'].remove("dagger")
inventory['gold'] = inventory['gold'] + 50
print inventory
The above keeps bringing up the same error message i.e.
Did you remember to sort the list at inventory["backpack"]? I dont understand what it wants me to do


#4

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

inventory['pocket'] = ['seashell', 'strange berry', 'lint']

inventory['backpack'].sort()

inventory['backpack'].remove("dagger")

inventory['gold'] = inventory['gold'] + 50

print inventory