首页 > 解决方案 > Python: How to print all numbers except the multiples of 3

问题描述

In trying to print all numbers except multiples of 3 until 10, this program does not shows any output:

a = 1 

for a in range (1,10) :
    if a % 3 == 0:
        continue
    a+=1
    
    print (a)
    a+=1

标签: pythonpython-3.x

解决方案


只需简化为:

for a in range(1,10):
    if a % 3 != 0:
        print(a)

推荐阅读