15.6 I can't work out what I've done wrong


#1


For some reason it returns none instead of true or false.


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


#2

@blogjumper40611: Are you using the print statement right before the function call?


#3

I am now (also switched where true and false are because I had them backwards) but now its giving me false and none.


#4

@blogjumper40611: I just tested your code, considering the changes in the sequence True and False to False and True.
Here's a screenshot:

Your code can only give you None if you don't print anything at all or False in case the number it's not a prime.


#5

Also consider that in the range, using x instead for x-1 as the stop. They want x-1 as the last thing in the range and when I had this problem, it took me like 3 hours to figure it out because the instructions were so vague.