Removing Elements from lists stored under keys in a Dictionary


#1

How do I remove an element in a list, that is under a key in a dictionary?


#3

the function remove function like this

backpack = ['xylophone', 'dagger', 'tent', 'bread loaf']
backpack.remove('dagger')

in his case I want to remove "dagger"


#4

but what if the list is inside a dictionary wizmarco?


#6

in the dictionary

inventory = {

'gold' : 500 + 50,
'pouch' : ['flint', 'twine', 'gemstone'], # Assigned a new list to 'pouch' key
'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']
}

inventory['backpack'].remove('dagger')

from backpack remove dagger


#7

thank you thank you thank you :slightly_smiling: :slightly_smiling: :slightly_smiling: