Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

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