Tuesday, October 7, 2014

Day 132

Spent some time reading about C# and Objective C. Figured I would do a little more Python in the meantime. Python at CodeCademy. Worked on Python tutorial 14 of 14, Python Lists and Dictionaries: Remove a Few Things! Worked on removing something from a list and putting it all together.

The code used: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()

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

There was no interaction for this code:

No comments:

Post a Comment