I’m stuck on this exercise. So far, the code is working fine, the only problem is with calling is_prime(9), returning True instead of False.
If we put it in the function it would be “if 9 % n == 0” return False and for n=3 it is 0. So why isn’t it returning False?
Also, it’s messed up with 49, 69, 99 and everything else with ending on 9…
Help/explanation much appreciated
def is_prime(x): if x <= 1: return False elif x == 2: return True else: for n in range(2, x): if x % n == 0: return False else: return True