I got stuck!


 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']

I canĀ“t do the last point!
Add 50 to the number stored under the 'gold' key


Your syntax is wrong! Write it with += instead of =+.
Hope this helps :slight_smile:


@maverba ,

If you add this at the end of your code, as a test ...

print inventory['gold']

... you will get this output ...


That is because +50 is equivalent to 50. Python interprets this ...


... as being the same as this ...

inventory['gold'] = +50

... which is an assignment of +50 to inventory['gold'], rather than an augmented assignment that increases the value of inventory['gold'] by 50. Technically what you have is valid syntax, but it performs the wrong operation for this exercise.


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