Created
August 8, 2016 20:07
-
-
Save Gwith/e8a984a4491e952350d9c1aa7f670431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def displayInventory(inventory): | |
print('Inventory') | |
for k, v in inventory.items(): | |
print(v, k) | |
print('Total number of items:' + ' ' + str(sum(inventory.values()))) | |
def addToInventory(inventory, addedItems): | |
for i in range(len(addedItems)): | |
inventory[i] = inventory.get(i, 0) + 1 | |
return inventory | |
inv = {'gold coin':42, 'rope':1} | |
dragonLoot = ['gold coin','dagger','gold coin','gold coin','ruby'] | |
inv = addToInventory(inv, dragonLoot) | |
displayInventory(inv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment