def is_prime(x):
if x < 2:
return False
else:
for n in range(2, x):
if x % n == 0:
return False
else:
return True
print is_prime(9)
returns True
instead of False
.
I don't quite understand.
The range (2,9)
includes this list: 2,3,4,5,6,7,8
and 9 % 3 == 0
,
So how come I do not get False
as the answer of that function?