def all_primes(start,end):
list_nonprimes = []
list_primes = []
for i in range(start,end):
for a in range(2,i):
if i % a == 1 and i not in list_nonprimes:
if i not in list_primes:
list_primes.append(i)
else:
list_nonprimes.append(i)
return list_primes
为什么这会给我一个不正确的输出?
>>> all_primes(1,10)
[3,5,7,9]
如何消除9?