0
Sum of even
The input from the keyboard numbers are given (one at a time). You need to display the sum of all even numbers. Entry stops if an empty string ("") is entered. In any situation, when even numbers do not come across, you need to display 0 (for example, numbers were not entered at all or only odd numbers were entered). Whats wrong? https://code.sololearn.com/cmwPsgh0Ubpb/?ref=app
8 Answers
+ 9
The logic could be like this: (Slick, please check your code if an empty string is input)
s = 0
while True:
a = input('enter a number: ')
if a == "":
break
elif int(a) % 2 == 0:
s += int(a)
print(s)
+ 7
Your program has an infinite while loop
+ 1
Just need to convert the input to a number and fix missing indentation. look here at fixed code
https://code.sololearn.com/crJAos2d2DQF/?ref=app
+ 1
Arnesh, and now? https://code.sololearn.com/cOiwyh0lTfPz/?ref=app
0
Lothar, if a == "" - right?
0
Thanks, so much.