Exactly. The else belonging to the if would be wrong, as a number is only not a prime when all numbers have been checked. So yes, this is best as a for...else in python with the else getting active whenever the loop didn't break prematurely. Quite a neat construct.
5
u/jamuzu5 Aug 27 '25
For the first loop, i =1.
First loop if statement:
Is n%1 == 0? Yes!
Next line prints "it is not a prime number"
Break and exit the loop.
Also, your last 3 lines aren't indented enough. Needs 1 more tab on each line.