Is_prime


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/6?curriculum_id=4f89dab3d788890003000096


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
    else:
        for n in range(2, x):
            if x % n == 0:
                print False
            else:
                print True


#2

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.


#3

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


#4

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


#5

A post was split to a new topic: Is prime


#6

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