Help(That’s Odd code coach problem ) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help(That’s Odd code coach problem )

I am having trouble with the first part of the code. The second part is easy( adding even numbers and retuning sum) 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

20th Feb 2021, 12:02 PM
Javier
Javier  - avatar
5 Answers
+ 3
Oh, ok then append input() to list n times //for i in range(n) : ...
20th Feb 2021, 12:37 PM
Angelo
Angelo - avatar
+ 2
Also, here are some tips: Take int(input()) instead of input() And B=[] for x in A: if condition: B.append(f(x)) Can be shortened in B = [f(x) for x in A if condition]
20th Feb 2021, 12:47 PM
Angelo
Angelo - avatar
+ 1
I am having trouble writting code for taking multiple inputs. The first number represents the number of inputs that follow. I have the code for the second part of the problem (getting sum of even numbers) if int(x)% 2 == 0: even.append(int(x)) print(sum(even)) but I don’t know how to take multiple inputs. Any help is appreciated. Thanks
20th Feb 2021, 12:32 PM
Javier
Javier  - avatar
+ 1
Awesome! Thank you for the help! It worked :)
20th Feb 2021, 10:33 PM
Javier
Javier  - avatar
0
For each element in the list, if it's even, add to the total Just translate in python that sentance
20th Feb 2021, 12:20 PM
Angelo
Angelo - avatar