Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

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

this code works for all numbers except x=9. whats wrong in this code?


You could add prints in your code to write out what’s being done.

That’s a really strong statement. There exist a whole lot of numbers.


9 is not prime
3 * 3 = 9


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