0
inventory = {'gold' : 500,
'pouch' : ['flint', 'twine', 'gemstone'],
'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']}

how do i delete the item 'dagger' only from the 'backpack'

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by Lucaci Andrew
0

This might help you:

try:
    inventory.get('backpack').remove('dagger')
except ValueError:
    pass

Edited by Lucaci Andrew

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.