The second loop tries to repeat for the range (2,2) in the first iteration. Which is effectively while
is greater than 2 and less than 2: but that is impossible so the loop terminates. So the output starts at 3 which is the next iteration of the outer loop when
has a value of 3.
If you look at the output from the second loop you can see the first line output is :
But you know that 2 is not a prime so how did that happen? Simply because your
clause is only indented once so it belongs to the preceding
statement rather than the