How do I complete 'It's Dangerous to Go Alone! Take This'?


#1

This is what I executed:

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']
inventory['pocket'] = ['seashell', 'strange berry', 'lint']

Sorting the list found under the key 'pouch'

inventory['pouch'].sort()

backpack.sort()
backpack.remove('dagger')
for number in gold:
print number + 50


but it is wrong. what should I do?


#2

Make sure that the code which you are posting is intact
Describe how your code behaves differently from what you expect, "wrong" is insufficient
Explain what you are trying to do right now, what information are you missing to move on?


#3

these were the instructions:
01. Add a key to inventory called 'pocket'
02. Set the value of 'pocket' to be a list consisting of the strings 'seashell', 'strange berry', and 'lint'
03. .sort() the items in the list stored under the 'backpack' key
04. Then .remove('dagger') from the list of items stored under the 'backpack' key
05. Add 50 to the number stored under the 'gold' key

this was the code that was manually in the editor:

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


#4

I am getting some funny results....I keep getting that dagger isn not in backpack when I try to remove it.
so i tried a test....I reset the code to what is given to us originally and right after the dictionary is defined i put in a line with the following
print backpack
the result is it prints our ['xylophone', 'bedroll', 'bread loaf']
for some reason it does not see 'dagger' that was defined in dictionary and thus give me an error when I try to remove it from dictionary.....weird...and frustrating


#5

I know this is late but I searched this for an answer and could not find one then I figured it out. The correct code to remove 'dagger'..

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

Hopefully this helps someone else.