Write a program to print sum of all even numbers in a list


Topic: Write a program to print sum of all even numbers in a list

Solution

ls = [1,2,3,4,5,6,7,8,10,22]
sum = 0
for i in ls:
    if i % 2 == 0:
        sum += i
print(sum)



List all Python Programs