📜  如何在python代码示例中仅对偶数求和

📅  最后修改于: 2022-03-11 14:47:20.278000             🧑  作者: Mango

代码示例2
>>> 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
>>>