It's Dangerous to Go Alone! Take This


#1



https://www.codecademy.com/en/courses/python-beginner-en-pwmb1/2/5?curriculum_id=4f89dab3d788890003000096#


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'
inventory['pouch'].sort() 

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

inventory['backpack'].sort()

inventory['backpack'].remove("dagger")

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


#2

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.


#3

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