Why don't my code work?

def sum_even_keyss (my_dictionary):
sum_1 = 0
for key, value in my_dictionary.items():
if key % 2 == 0:
sum_1 += value
return sum_1

please tell me why this one don’t want to work ?
an i have results “0” for first print and “1” for second print
I don’t understand why it’s stop at first key.

Lets say you make a test, and each question on the test represents an iteration of the loop. You can fill in the first question, leave the remaining questions open and return/hand back the test to your teacher

which is what is happening with the return in your code a well, given the return keyword is nested in the loop

3 Likes