from math import sqrt
for num in range(2,100) :
flag = True
for sub in range(2,int(sqrt(num))+1) :
if num % sub ==0 :
flag = False
break
print num ,
我是python中的“品牌”新手,我尝试将代码从2输出到100,然后我 遇到一些问题,请帮帮我^^
答案 0 :(得分:4)
for sub in range(2,int(sqrt(num))+1) :
if num % sub ==0 :
flag = False
break
print num , # <<-- this is inside the for loop and will be printed every iteration