Oops, try again. Your function fails on is_prime(4). It returns True when it should return False.

def is_prime(x):
    if x < 2:
        return False
    elif x == 2 or x == 3:
        return True
        for n in range(2, (x - 1)):
            if  x % n == 1:
                return False
                return True


I am doing something wrong here cant figure out. need help.



if  x % n == 1:

you want to check if the remainder equals zero, if this is the case, return False.

Also, a function ends the moment a return keyword is reached.This currently happens in the first iteration of your loop, you only should return True after the loop has finished running (hint: indention)

If you need more help, post an updated version of your code


Worked :slight_smile: thanks, was able to fix it.



well done! you did most of the work