3.2.1 Syntax and Anatomy of the While Loop

Unit: Unit 3: Loops • Interactive Practice

Quick Answer & Summary:

Interactive Python programming tutorial and practice in your browser.

Interactive Challenge (Run Live in Browser):

# Print powers of 2 less than 50 using a while loop
value = 1  # 1. Initialization

while value < 50:  # 2. Condition check
    print("Current value:", value)
    value *= 2  # 3. State update

print("Loop concluded. Final value:", value)
Open in Live Interactive Python Sandbox →