0

what's wrong with my code?

That's odd... +50 XP 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 //here's my code numbers = [] lenNumbers = int(input("Enter length of list:")) for N in range(lenNumbers): num = int(input("Enter numbers:")) numbers.append(num) n = 0 i=0 while (i<=len(numbers)-1): if numbers[i]%2 == 0: n += numbers[i] i+= 1 print (n)

29th Aug 2020, 11:20 AM
14BobuR14
14BobuR14 - avatar
3 Respostas
+ 8
Nothing ,remove those statements passed to the input function tho ,since code coach wants only answer as an output not those strings
29th Aug 2020, 11:27 AM
Abhay
Abhay - avatar
+ 3
thanks bro it worked
29th Aug 2020, 11:49 AM
14BobuR14
14BobuR14 - avatar
+ 2
Why don't you add the even numbers in your for loop?
29th Aug 2020, 11:54 AM
Paul
Paul - avatar