14. It's Dangerous to Go Alone! Take This


#1


Hey everyone,
I am not able to complete this assignment because i am getting an error message stating this:
Oops, try again. It looks like you did not add the "pocket" key.

Anyone know whats wrong with my code?


#2

It asks you about inventory['pocket'], you could start by finding out if it's there by printing it:

print inventory['pocket']

#3

You forgot the c in pocket. In your code you wrote poket.


#4

lol...well that was an easy fix...I suppose I was looking too high level ha ha ha


#5

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['poket'] = ['seashell','strange berry','lint']
print inventory['poket'][0]
inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold'] = inventory['gold'] + 50

Oops, try again. It looks like you did not add the "pocket" key.


#6

HI this line

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

you wrote poket instead of pocket


#7

thank , you r vey intelligent <3


#8

At the end of your code use print inventory


#9

Here's my code:

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']
print inventory['pocket'][0]
inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold'] = inventory['gold'] + 50

hope this helps someone.


#10

this was helpful. Thank you


#11

how to ask a question here ?


#12

inventory['gold'] = inventory['gold'] + 50
this code gives an error


#13

Works fine on my computer. hmm? maybe try refreshing the page, what does your error say? I went back and double checked it worked and it all seemed fine, it should say seashell in the little window. If anyone can see an error let me know. but it did work. hope this code works for everyone else! :upside_down:


#15

Did you use the spacebar correctly?


#16

sorry for the late reply im too busy to notice it...thanks guys it working now


#17

Thank you! I didn't know how to add 50


#18

Well, that was rhetorical. Slayer, are you serious?


#19

Thank you. It is helpful to me.


#20

This worked fine for me and you do must not count for the index of dagger and print the whole inventory on screen :smiley:

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["pocket"] = ["seashell", "strange berry", "lint"]
dagger_index = inventory["backpack"].index("dagger")
del inventory["backpack"][dagger_index]
inventory["backpack"].sort()
inventory["gold"] += 50

print inventory["gold"]
print inventory["pouch"]
print inventory["backpack"]
print inventory["pocket"]


#23