14/14 Lists and Dictionaries HELP!

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:

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.

4 Likes

Thanks so much! :smiley:

You’re very welcome :slight_smile:

1 Like

inventory[‘pocket’] = [‘seashell’, ‘strange berry’, ‘lint’]

1 Like

Look

line 14

7 Likes

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

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

1 Like

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

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

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…

Hi guys ,
This will definitely work…

1 Like

Thanks bro it’s really helpful

none of the codes work for me please help

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

oh i got this code a long time ago

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!

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.