Hey there,
i'm stuck at this exercise:

This is the error message i get:
Oops, try again.
Your function fails on is_prime(9). It returns True when it should return False.

I dont quite get it. My code and comments below:

def is_prime(x): #lets take 9 as the example
    if x < 2: #pass
        return False
    elif x == 2: #pass
        return True
        for n in range(2, x -1):
            if x % n == 0: #here it should give me the return False, because 9%3 is 0, isnt it? Why is the error message that it returns True?
                return False
                return True

Thanks for all your help!


There was an exact same topic earlier today:


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