The second loop tries to repeat for the range (2,2) in the first iteration. Which is effectively while
x
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
n
has a value of 3.
If you look at the output from the second loop you can see the first line output is :
2 prime
But you know that 2 is not a prime so how did that happen? Simply because your
else
clause is only indented once so it belongs to the preceding
for
statement rather than the
if
.