Error in test 3 of That's Odd... Code Coach | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Error in test 3 of That's Odd... Code Coach

a =int(input()) n = [] counter = 0 sum = 0 while a > counter: b = (input()) n.append(b) counter += len(b) for x in n: if int(x) % 2 == 0: sum += int(x) print(sum) Why does this fail the third test?

30th Apr 2022, 7:20 PM
Thiago Silva
Thiago Silva - avatar
2 Answers
+ 6
counter += len(b) I am not sure what you are trying here. If you change this line to a -= 1 your code works. And you can remove variable counter: while a > 0: b = int(input()) So you don't need to convert x to int. And theoretically you don't need to create the list. while a > 0: b = int(input()) if b % 2 == 0: .... Happy coding!
1st May 2022, 6:56 AM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Thank you!
1st May 2022, 10:46 AM
Thiago Silva
Thiago Silva - avatar