Skip to content

Instantly share code, notes, and snippets.

@Gwith
Created August 9, 2016 03:26
Show Gist options
  • Select an option

  • Save Gwith/ff229cc18ee862f4495c16552e48c99e to your computer and use it in GitHub Desktop.

Select an option

Save Gwith/ff229cc18ee862f4495c16552e48c99e to your computer and use it in GitHub Desktop.
def addToInventory(inventory, addedItems):
for item in addedItems:
inventory[item] = inventory.get(item, 0) + 1
print(inventory)
inv = {'gold coin': 42, 'rope': 1}
dragonLoot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby']
addToInventory(inv, dragonLoot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment