Oops, try again. Your function fails on is_prime(9). It returns True when it should return False.
I can't figure this one out. I thought that x % n == 0 could handle is_prime(9). I was reading other people's questions about this exercise, and the moderators talked about how a function ends when a return keyword is reached. How can I fix mine so that this doesn't happen?
def is_prime(x): if x < 2: return False elif x == 2: return True else: for n in range(2, x): if x % n == 0: return False elif x % n != 0: return True