Python Foundations · Lesson 7 of 12Condition-controlled loops
while loops, sentinels and avoiding infinite loops. Learn through short examples, practical tasks and targeted questions.
← All lessons
Repeating with while
A while loop checks its condition before every repetition. It works well for menus and input that continues until a sentinel value is entered. Identify which variable changes inside the loop and explain how the program eventually stops.
Watch out: If the loop condition never becomes false, the program can repeat indefinitely. Check both the starting state and the update.
A free TutorSyntax programming lesson. About our teaching approach.