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

# Please explain this code to me sir, I don't understand how it is written. What for instance does x - 1 do

**qlueless**#1

**stetim94**#2

well, we don’t want to include `x`

in our loop. We want values lesser then `x`

, so we need `x - 1`

however, range does not includes its stop value, so you don’t need minus one.

**system**#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.