Oops, try again. Make sure to add 50 to the gold total! [code inside]


#1



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'] = [int(inventory['gold']) + 50]

above are my codes, wonders why it doesn't work.

help is much appreciated!


#2

to give a key a new value we can do:

dictionaryName[keyName] = "new value"

but in your case we need to update the value:

example = {"test": "hello"}
example["test"] = example["test"] + " world"

you use too many square brackets, why? If you explain, i can correct your tought process


#4

thanks so much. I really have no reason of using so many brackets. All I thought was to use the function int.(). Probably that is why


#5

but using int() doesn't mean you have to additional square brackets, any way, good that you solved it :slight_smile:


#6