A while loop in Python programming repeatedly executes a target statement as long as a given condition is true. If found this chart and want to show it to you as it describes the way of using while-loops pretty good:
So what we can see is that you define a condition and if it turns true the assigned conditional code will be executed otherwise the loop ends.
In most soccer stadiums in Germany the stadium announcer calls the name of every player at least 3 times and the fans have to repeat them everytime. For the best players the fans shout “Fußballgott” (god of soccer) three times. How can we implement this in Python:
The next thing I want you to understand is how loops into loops function. Imagine the stadium announcer says the name of the player one time than the fans scream “Fußballgott” three times and then the stadium speaker says the name one more time:
Methaporically spoken, when the fans beginn to sign it is first their turn to finish their part until its the announcers turn again. So first the inner loop will be completed until it jumps back to the outer part.
I hope you understood the basic functionality of the while loop. If you want to get further information e.g. what to do with the “break” or the “continue” into a loop have a look at this resource: