It's Dangerous to Go Alone! Take This


How to add Add 50 to the number stored under the 'gold' key

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'

# Your code here
inventory['pocket'] = ['seashell','strange berry','lint']



inventory['gold'] = 500, 50

the last line
inventory['gold'] = 500, 50
i tryed it, but it is wrong,i d'not know how to add an item to a key


is a value. We can change that value in any number of ways, but the one suggested here is augmentation.

inventory['gold'] += 50

The compound operator is one you will familiarize yourself with, if you haven't already.


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