Is_prime


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/6?curriculum_id=4f89dab3d788890003000096#

<In what way does your code behave incorrectly? Include ALL error messages.>
Your function fails on is_prime(5). It returns None when it should return True.

<What do you expect to happen instead?>
shouldn’t is_prime(5) work properly?

def is_prime(x):
    if x<2: 
        return False
    elif x==2:
        return True
    elif x==3:
        return True
    else:
        for n in range (2,x-1):
            if x%n==0 :
                return False
                break
            else:
                if n!=(x-1):
                    continue
                else:
                    return True

#2

here:

if n!=(x-1):

this condition will never evaluat to false because x-1 isn’t ran by the loop


#3

oh!!!
i didn’t recognize that
such a silly mistake
really appreciated for you help


#4