Skip to content

Instantly share code, notes, and snippets.

@stevencombs
Created August 11, 2013 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencombs/6207219 to your computer and use it in GitHub Desktop.
Save stevencombs/6207219 to your computer and use it in GitHub Desktop.
# Number is Integer or Float - return Absolute Function
# A Codecademy Python (It's Dangerous to Go Alone! Take This) list and dictionary assignment
# Dr. Steven B. Combs, coding novice
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
inventory['pocket'] = ['seashell', 'strange berry', 'lint'] # Add key and a list to that key
inventory['backpack'].sort() # Sort the backpack list
inventory['backpack'].remove('dagger') # Remove dagger from backpack key
inventory['gold'] = 550 # Replace gold with 550
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment