14/14 Lists and Dictionaries HELP!


#1

I don't know where I went wrong...

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

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

This is what it said...

File "python", line 14
'pocket': ['seashell', 'strange berry', 'lint'],
^
SyntaxError: invalid syntax

It would be really great if you could help me, or tell me where I went wrong!
:grin: :strawberry: :doughnut: :crown: :cookie: :blush:


Can't figure out last line:) to add 50 to gold :( nothing works . #14
#2

Problem is in this line:

'pocket': ['seashell', 'strange berry', 'lint'],

Instruction:

Add a key to inventory called 'pocket'

How your computer can know that you want to add this key to the inventory? :smile:

You have to use exactly the same syntax that was used here:

inventory['burlap bag'] = ['apple', 'small ruby', 'three-toed sloth']

Just change the name of the key to 'pocket' and elements.


#3

Thanks so much! :smiley:


#4

You're very welcome :smile:


#5

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


#6

Look line 14


#7

for the inventory pocket bit that you screen shoted, it says that i am missing something???


#8

same here.

my code (in portuguese):

inventory = {
'gold' : 500,
'pouch' : ['silex', 'barbante', 'pedra preciosa'], # Atribuido uma nova lista a chave 'pouch'
'backpack' : ['xilofone','adaga', 'saco de dormir','pedaco de pao']
}

Adicionando uma chave 'burlap bag' a atribuindo uma lista a ela

inventory['burlap bag'] = ['maca', 'pequeno rubi', 'bicho preguica']

Organizando a lista encontrada sob a chave 'pouch'

inventory['pouch'].sort()

Seu codigo aqui

inventory['pocket'] = ['concha', 'amora', 'estranha', 'sujeira']

inventory["backpack"].sort()
inventory["backpack"].remove('adaga')
inventory["gold"] += 50
print inventory


im almost sure that everything is correct but it appers:

Oops, try again. It seems that you do not have all the correct items in inventory ["pocket"].

pls help me


#9

Amora estranha is a single element, so it should be:

inventory['pocket'] = ['concha', 'amora estranha', 'sujeira']

#10

yes, it does work,
but would you tell my please why the order it print is as below:
pocket/backpack/burlap/gold

thank you for answering....


#11

Hi guys ,
This will definitely work.........


#12

Thanks bro it's really helpful


#13

none of the codes work for me please help


#14

Hi can you post your code And The erro you get?


#15

oh i got this code a long time ago


#16

I'm on this exercise but for some reason can't get pass the final "Add 50 to the number stored under the 'gold' key" I keep getting a syntax error. Even when i put in the same line of code as in the previous screen shots i still get this error, any idea what im doing wrong? Thanks in advance for the help!


#17

Invalid syntax errors usually indicates that something is not ok in the previous line (line number 17). You need to add ].

Next time please create new discussion.