Practice makes perfect


#1



im having difficulties trying to solve this excersise. i keep getting the error "Your function fails on is_prime(9). It returns True when it should return False." and i dont know why this is happening, I was hopeing someone could help me understand what i have done wrong/missed :slight_smile: 

def is_prime(x):
    if x<2:
        return False
    elif x == 2 or x == 3:
        return True
    else:
        for n in range(2,x):
            if x % n == 0:
                return False
            else:
                return True


#2

Check your code inside the for cycle, in the if condition. Who's n?


#3

I have looked at it several times and am still rather stumped, is it possible if you can elaborate a bit more :slight_smile:


#4

Oh man I'm sorry, I just realised I was totally mistaken and thinking something very different. I'm still trying to figure out the logic though, maybe paste the instructions? Sorry! :confused:


#5

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