+ 4

That's odd

a=int(input()) s=0 for i in range(a): n=int(input()) if(n%2)==0: s+=n print(s) You want to take a list of numbers and find the sum of all of the even numbers in the list. Ignore any odd numbers. Task: Find the sum of all even integers in a list of numbers. Input Format: The first input denotes the length of the list (N). The next N lines contain the list elements as integers. Output Format: An integer that represents the sum of only the even numbers in the list. Sample Input: 9 1 2 3 4 5 6 7 8 9 Sample Output: 20 What's wrong

11th Nov 2020, 2:49 PM
Harshita Kumari
Harshita Kumari - avatar
2 odpowiedzi
+ 11
I guess it's some indentation error, for i in range(a): n=int(input()) if(n%2)==0: s+=n
11th Nov 2020, 2:55 PM
Abhay
Abhay - avatar
0
Yes
5th Jun 2022, 10:56 AM
Francis Kwame Owusu