Skip to content

Instantly share code, notes, and snippets.

@Gwith
Created August 9, 2016 22:49
Show Gist options
  • Select an option

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

Select an option

Save Gwith/e477254cbf8a7cf1971bbb7741ee1ca5 to your computer and use it in GitHub Desktop.
test1 = { 'cat' : 1, 'dog' : 1, 'bird' : 1}
test2 = { 'cat' : 3, 'dog' : 2, 'cow' : 2 }
for key, value in test1.items():
test1[key] = test2.get(key, 0) + test1[key]
print(test1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment