+ 1

Please help I'm stuck here i know I have to add even numbers but I don't know how

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 # user input length_of the list length_of_the_list = int(input()) # input list elements list_elements = int(input()) # make a list of even numbers even_numbers = list_elements % 2 == 0 # getting even numbers if list_elements % 2 == 0 :

10th Nov 2021, 4:20 PM
siviwe sam-sam
4 Answers
+ 4
Then I recommend you to continue your study first, until you have learned how to use a loop for reading multiple inputs. Use of loop in this types of task is necessary 👍
10th Nov 2021, 5:05 PM
Ipang
+ 3
Have you learned how to use a loop to read multiple inputs? Considering the list elements are required to be read line by line, you will need to use a loop to read the N number of elements programmatically.
10th Nov 2021, 5:00 PM
Ipang
+ 2
No I haven't
10th Nov 2021, 5:02 PM
siviwe sam-sam
+ 2
Thanks
10th Nov 2021, 5:05 PM
siviwe sam-sam