My code goes wrong. It returns the error


#1

My code goes wrong. It returns the error "Your function fails on is_prime(2). It returns False when it should return True".
Can anybody tell me the reason

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

15.6 - is_prime
#2

Hi,
I formatted the code. Please check if its indentation is the same as what you wrote before we proceed. I say this because your code had bit weird indentation.