1. What is a while loop?
Explain simply:
“A while loop keeps running as long as a condition is True.”
2. When should you use a while loop?
Use while when you don't know exact
🔄 FOR vs WHILE
Situation
Use
You know how many times to repeat
for
You want to iterate over a list/string
for
Repeat until a condition changes
while
User input determines when to stop
while
1 → 100
for
Keep asking until correct input
while
🧠 Simple rule for beginners
FOR = “How many times?”
WHILE = “Until when?”
#ai #machinelearning #python #artificialintelligence #datascience #chatgpt