Why is n=2 returning true?

I don’t understand the solution they have given:

def is_prime(x):
##if x < 2:
####return False
##else:
####for n in range(2, x-1):
######if x % n == 0:
########return False
####return True

For is_prime(2) it somehow gives True, yet 2 /2 =1, so 2 % 2 == 0, which should return False. What am I missing?
Also, in the range function why is it not range(2, x) as range functions don’t include the number after the comma? I assume no number divided by the previous number gives % == 0 (except possibly 2), but still it seems more certain to use x.

i assume by so 2 % 2 == 0 you mean the if condition? Excepts the code never gets there, the for loop never makes any iteration, given the loop condition is false from the start

never understood that, range(2, x) works just as well.

Great thanks, of course there is no n in range(2,1) or range(2,2), so it ignores the iteration. Thanks for your help.