[Solved] Understanding python while loop [closed]


The condition is tested before each iteration of the loop, not after every statement inside the loop body. So even though queue.pop(0) empties the list, you still execute the next statement and print the message.

Then it goes back to the beginning and tests queue again. This time the condition fails and the loop terminates.

2

solved Understanding python while loop [closed]