So I eventually got the right answer by using "==" in if statement and switching boolean values at bottom. But I'm still curious as to why the code below doesn't work with "=!".
"You function fails on is_prime(2)" It returns "false" and should return "true"" is the error I'm getting. I've looked at some of the other posts on this problem but none that I've seen use != 0. I thought that made more sense since the function is called is_prime (hence you want to return a value of "true" when the argument is a prime number.
Thanks in advance!!
def is_prime(x): if x < 2: return False elif x >= 2: for n in range(2, x): if x % n != 0: return True return False print is_prime(7)