+ 4
How to find the sum of all even integers in a list of numbers in python
.
8 ответов
+ 4
deepak Kumar , It's common when asking a question about help for coding to show the own attempt first.
But as there are already some solutions given, I will also throw my hat in the ring:
l = [1,4,7,10,13,16]
print(sum([i for i in l if i % 2 == 0]))
+ 3
Arshia , the task was to sum all even integers from a list. Your code just prints the even integers. That is a good start. Try to add the functionality to sum these values. 👍
+ 2
Specify a relevant language in your tags please (replace the dot with a language name), proper tags improves context clarity 👍
+ 2
That's odd... SoloLearn problem solved!
https://code.sololearn.com/c9mztWPbZn2n/?ref=app
+ 1
Mirielle[ InAcTiVe ] you have to write i&1, not i&2.
+ 1
for i in list:
if i % 2 == 0:
print(i)