Don't know wheres my mistake (is_prime


Oops, try again. Your function fails on is_prime(0). It returns None when it should return False.
don't know what is my mistake and im stuck in this lesson

def is_prime(x):
    for n in range(2, x - 1):
        if x % n == 0:
            return False
            return True


Your code will return True for all odd numbers, and None for numbers 2 or less.

To solve the first problem, remove the else branch. Only go with an if and only return False.

To solve the None issue, return True at the end of the function.

That will leave you with only one problem. I don't want to spoil the mystery...


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