Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, November 28, 2012

Codecademy: It's Dangerous To Go Alone!...


#sample solution


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()
# Here the dictionary access expression takes the place of a list name

# Your code here
inventory['pocket'] = ['seashell', 'strange berry', 'lint']
inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold'] = inventory['gold'] + 50

print inventory

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Thank you so much for this code, you saved me!

    ReplyDelete


This is an example of scrolling text using Javascript.

Popular Posts