Created
August 9, 2016 02:52
-
-
Save Gwith/fbaa4291895cb72a5497268375bfe233 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 pprint | |
| stuff = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12} | |
| def displayInventory(inventory): | |
| print("Inventory:") | |
| item_total = 0 | |
| for k, v in inventory.items(): | |
| print(v, k) | |
| item_total += v | |
| print("Total number of items: " + str(item_total)) | |
| displayInventory(stuff) | |
| def addToInventory(inventory, addedItems): | |
| for item in addedItems: | |
| inventory[item] += item | |
| 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