鄙人也是看着写的,如果哪位苦逼大学生跟我一样需要他,就请便吧:
range1=int(input('请输入想要求的范围'))
sum=0
for num in range(2,range1+1):
for x in range(2,num):
if num%x==0:
print('%d*%d=%d,it is not a prime number'%(x,a:=num//x,num))
break
else:
print('%d seems like a prime number'%num)
sum+=1
print(f'the work is over,{sum} prime numbers in this list')
这个代码是我在学习continue和break的时候的随堂测。不是太难