I'm confused about why my code isn't working. Perhaps it's because I'm using print. The error is on is_prime(1) it should return false instead of true.

def is_prime(x):
if x == 0:
return False
for n in range(2, x - 1):
if x % n == 0:
print False
print True
return True


For starters, yes. Your if statement should not have an else branch.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.