Don't know wheres my mistake (is_prime


#1



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

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
        else:
            return True


#2

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...


#3

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