14 in python lists and dictionaries. HELP PLEASE


#1

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

the error message:
Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: list.remove(x): x not in list


#2

@ammar847: That's because "dagger" is not on your dictionary and such won't be able to be removed.
Check the instructions and see whether your dictionary or item to be removed is incorrect.


#3

Here is my code:
but I am not satisfied with the last line (Add 50 to the number stored under the 'gold' key), could you share yours with me?

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


#4

that is definitelly not 50 :slight_smile:
you can assign 50 like this:

inventory['gold'] = 50

or you can add 50 to the number alrady in 'gold':

inventory['gold'] += 50