Something wrong with 'backpack'


#1

1 inventory = {
2 'gold' : 500,
3 'pouch' : ['flint', 'twine', 'gemstone'], # Assigned a new list to 'pouch' key
4 'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']
5}
6
7# Adding a key 'burlap bag' and assigning a list to it
8inventory['burlap bag'] = ['apple', 'small ruby', 'three-toed sloth']
9
10# Sorting the list found under the key 'pouch'
11inventory['pouch'].sort()
12
13inventory = {'pocket': ['seashell', 'strange berry', 'lint']}
14inventory['backpack'].sort()
15inventory['backpack'].remove('dagger')
16inventory['gold'] += 50

im being told that there is something wrong with 'backpack' on line 14 & 15, can anyone see what it is because I sure cant

ps the numbers aren't in the code they are just to see what line the code is on


Did you accidentally delete the `inventory` dictionary? Click Reset Code to get back to the original code
#2

The above is re-defining inventory, effectively wiping out everything that was previously in it.

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

#3

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