Its dangerous to go alone


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 = {‘pocket’ : [‘seashell’, ‘strange berry’, ‘lint’]}

inventory[‘gold’] + 50

The error is Traceback (most recent call last): Thanks for any help!
File “python”, line 14, in
KeyError: ‘backpack’


Hi @goldenmatrices,

Here, you assigned an entirely new dictionary to inventory, with only the key, 'pocket'

inventory = {‘pocket’ : [‘seashell’, ‘strange berry’, ‘lint’]}

After that, it no longer has a 'backpack' key.

Instead, add a new item with the key, 'pocket', to the existing dictionary, as follows …

inventory['pocket'] = ['seashell', 'strange berry', 'lint']


Okay thank you! It works now!