Following is the error message:

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

Replace this line with your code. 
def is_prime(x):
    if x<2:
        return False
    elif x==2:
        return True
        while x>2:
            for n in range(2, x-1):
                if x%n==0:
                    return False
                    return True


def is_prime(number):
    divisor = [num for num in range(1, number+1) if number % num == 0]
    return True if len(divisor) == 2 else False

Well, I also couldn't solve it as directed by Codecademy. So try my code.


you need change range Terminal
Look at this:
range(2, 8)
[2, 3, 4, 5, 6, 7]
Also, you need more False conditions. What will your function return, if n==x?


Thanks! It worked. Have a great weekend!


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