Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 1, 2020 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/987ff0029304953d6d7e24e9f7513d01 to your computer and use it in GitHub Desktop.
Save codecademydev/987ff0029304953d6d7e24e9f7513d01 to your computer and use it in GitHub Desktop.
Codecademy export
# Write your sum_even_keys function here:
def sum_even_keys(my_dictionary):
count = 0
for key in my_dictionary.keys():
if key%2 == 0:
count += my_dictionary[key]
return count
# Uncomment these function calls to test your function:
#print(sum_even_keys({1:5, 2:2, 3:3}))
# should print 2
#print(sum_even_keys({10:1, 100:2, 1000:3}))
# should print 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment