Oops, try again. Your function fails on is_prime(0). It returns True when it should return False.
I know this has been covered by other answers but I don't understand why mine can't work as well. An if statement can't go under a for loop here -- but don't we use conditionals in loops all the time? Why doesn't it work in this case even if return True exists outside the loop?
def is_prime(x): for n in range(2,x-1): if x%n == 0 and x <= 1: return False return True