for Loop vs while Loop in Python
for is for walking a known sequence or range: for name in names, for i in range(5). while is for “until this becomes false”: while not done, while line != "". You can fake one with the other, but readers suffer. Prefer for when you have items. Prefer while when the stop is a condition, not a list.
Best-fit examples: print each mark → for. Read input until quit → while. range belongs with for. Infinite risk belongs with while.
for Loop vs while Loop in Python — output: for Asha, for Ravi, while 2, while 1.
i = 1
│ i <= 3 ?
▼ yes
print(i); i += 1
│
▼ i = 4 → stopOne best-fit example for each loop.