Why it is not working?


#1

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[gold].remove('dagger')


#2

Isn't the dagger in the backpack?


#3

I didn't get you .
Please give little bit detail explanation


#4

inventory[gold] is undefined so should raise an exception.

inventory['gold'] is defined, but holds a single value, 500.

'dagger' is in the inventory['backpack'] list.

Do you want to remove 'dagger', or modify the value for 'gold'?


#5

What a silly mistake i have done there .
Thanx for figuring it


#6

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