Over here,
for n in range(2, x - 1):
the for loop never runs if x == 1, then, you are essentially saying:
for n in range(2, 0):
which can't happen, so it just returns True from the else
statement.
Your second function works because, as you said, the if statement is outside of the for
loop