Lists in dictionaries


#1



Hi guys, someone can help me with this exercise? Thanks


Replace this line with your code.


#2

Hi @systemninja32530,

We cannot help you unless you post your code (required), and the error you are receiving (optional). :slight_smile:


#3

Sorry, I had forgotten.
This is my complete 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']
k = inventory['backpack']
k.sort()
a = inventory['backpack']
a.remove('dagger')
inventory['gold'] + 50

And this is the error I have:
Oops, try again. Make sure to add 50 to the gold total!


#4

What is the variable k for? You are only supposed to add a key to inventory called pocket the same way you added a key named burlap bag here,

And then sort the backpack key using the .sort() method,

inventory['backpack'].sort()

Please fix those errors first, and then try follow the instructions but if you still need help feel free to ask. :slight_smile:


#5

I have solved...thank you for your help!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.