Not sure what I'm doing wrong?

Why is my code not accepted: Oops, try again. Your function fails on is_prime(0). It returns None when it should return False.

def is_prime(x):
    if x ==2:
        return True
    elif x < 2:
        return False
    if x > 1:
        for i in range(2,x):
            if (x % i ) == 0:
                return (False)


Try refreshing the cache etc. That code does return False for 0


ahhha wow I feel stupid now.
Thanks :slight_smile:


In last line you are just calling a function which is just returning the value instead of that you should print the function to be able to see whether it is true or false.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.