while — Advanced Playground
Starts a loop that repeats as long as its condition is true
Python Playground
Output
Click "Run" to execute your codewhile loops are natural for parsers and state machines where the number of iterations depends on the input content, not just its length.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?