>>> myList = [1, 3, 5, 6, 8, 10, 34, 2, 0, 3]
>>> result = 0
>>> for item in myList:
... if not item%2:
... result += item
...
>>> result
60
#2 + 4 + 6 + 8 + .......... + n = ?
l = int(input("Enter the range = "))
sum = 0
for x in range(2, l+1, 2):
sum += x
if x != l:
print(x, "+ ", end='')
else:
print(x, end='')
print(" =", sum)
>>> myList = [1, 3, 5, 6, 8, 10, 34, 2, 0, 3]
>>> result = 0 # Initialize your results variable.
>>> for i in myList: # Loop through each element of the list.
... if not i % 2: # Test for even numbers.
... result += i
...
>>> print(result)
60
>>>
def sum_evens(numbers):
total = 0
for x in numbers:
if x % 2 == 0:
total += x
return total
>>> lst = [0, 1, 2, 3, 4, 5]>>> sum(n for n in lst if n % 2 != 0)9