Your function fails on is_prime(4). It returns None when it should return False.

Hi, was wondering why this is not working...Thanks for your help!

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


in your for loop, you print true or false while you should return it

If you get a new error message, see if you can solve it. If not, reply to this topic and i will help you further.


when i use return it says "It returns None when it should return False/True."
Please help


the information you provided is insufficient, please go here, press the new topic button, fill in the template so you provide all the information we need to help you


A post was split to a new topic: Is prime


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