Why does this fail at prime(2)?


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

#2

u can just sum up the first if in just 1 condition
thats what i did tho (notice the indents)
def is_prime(x):
____if x <= 1:
________return False
____if x == 2:
________return True
____for n in range(2,x-1):
________if x % n == 0:
____________return False
____return True
EDIT: sorry i forgot the "2" part , thanks @ropnog


#3

2 is a prime number, but by saying
x==2
return False
youre saying 2 is not a prime.