Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to sum only the even values in python

>>> 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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sum #values #python
ADD COMMENT
Topic
Name
2+3 =