Is_prime


#1




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

that make me crazy, i tried every things

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


#2

Add prints to your code to investigate what it's doing wrong to get that result:

9 % 2 = 1
9 % 3 = 0
was able to divide, so 9 is not prime

#3

so what i can do to solve this ?


#4

This exercise is a little bit tricky but you are very close.
The range you need to divide the number by itself so x-1 is lower than the number itself

also add prints to make sure where you went wrong as ionatan advised


#6

By investigating what's going on. You can't jump to the fixing part, that's not how any of this works. Find out what you need to fix.


#9

Im not sure it works for is_prime(4)


#12