Generating a list of EVEN numbers in Python

前端 未结 14 621
轻奢々
轻奢々 2021-01-17 15:48

Basically I need help in generating even numbers from a list that I have created in Python:

[1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597         


        
14条回答
  •  -上瘾入骨i
    2021-01-17 16:25

    iterate through the list and use the modulo operator to check even

    for number in list:
        if (number % 2) == 0: 
            ##EVEN
    

提交回复
热议问题