Definition:
A while loop in Python is a control flow statement that allows a block of code to run repeatedly as
long as a specified condition is True. It is mostly used when the number of iterations is not known
in advance.
Syntax:
while condition:
# code block
Flowchart of While Loop:
How it Works:
• Step 1: Check the condition.
• Step 2: If the condition is True → execute the loop body.
• Step 3: After execution, go back and check the condition again.
• Step 4: If the condition is False → exit the loop.
Example 1: Basic Counting
i = 1
while i <= 5: