Hey, sorry you're having some trouble. Let's work this together.
if x < 2:
elif x > 2 and x != 3:
for n in range(2, x-1):
if x % n == 0:
OK...so, what's a prime number? It's a positive integer greater than 1 that has no positive divisors other than 1 and itself.
Alright, cool. With your current algorithm, you're just making it a bit too complicated.
x < 2 is a good starting point and can stay, because all prime numbers are greater than
1, therefore anything less can be considered not prime.
Now, however, the next bits are where you're getting a bit too complicated. Sure,
x > 2 is a good condition to check because all prime numbers are greater than
1, but it appears that you're missing
2 itself, which is prime. You are also checking to ensure the number is not
3 is prime as well.
So what you can actually do is remove that
elif altogether, because it is actually breaking your
is_prime implementation rather than helping it.
for loop where the
elif was beginning, and I think you'll find that things will start ticking the way you'd expect them to.
Extra note: You can move your ending
return True to the outside of the
for loop, so that it resides at the end of the function.