6. is_prime question


Hello guys. What is wrong with my code?

Thank you.


Figured it out :slightly_smiling:


for i in range(2,x) -- is not valid ,since it will give reminders zero when divided by itself
ex :

for i in range(2,7) -- 2-3-4-5-6-7

7%7 == 0 --- will satisfy the for condition and will return False while its should be true.

i think the correct range will be

for i in range(2,x-1):



Hi @projee, range(x, y) takes values starting from x, but goes only till y - 1 i.e. it doesn't include the y value. Hope it helps!

See on repl


Thanks for the explanation