Error message: Oops, try again. Your function fails on is_prime(-7). It returns True when it should return False.
I think my code is right, 7 is a prime number, so my function should return True. I don't know why the error message says that it should return False. Bug? Is there something wrong in my code?
def is_prime(x): x=abs(x) prime=True if x==0: prime=False elif x==1: prime=False elif x==2: prime=True else: for n in range(2, x-1): if x%n==0: prime=False return prime