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

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

This might help you:

try:
    inventory.get('backpack').remove('dagger')
except ValueError:
    pass
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.