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?
2 Réponses
+ 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!
+ 1
Thank you!