🧩Infinite Loop
Also known as Endless Loop
A loop that never ends. Usually a bug, and the program seems to freeze.
Think of it like
Think of it like a dog chasing its own tail. It goes round and round and never gets anywhere.
Example
Jack writes while n > 0 but forgets n = n - 1. The program prints 3 over and over until he presses Ctrl+C.
Why it matters
A stuck program wastes power and makes people think it crashed. Knowing the cause makes it quick to fix.
Definition
Example code
python
n = 3
while n > 0:
print(n) # n never changes
# 3, 3, 3, 3 ... until Ctrl+CCommon mistake
Key takeaways
- 1No way out. The end test never turns false.
- 2Looks frozen. The program works hard but shows nothing.
- 3Sometimes on purpose. A game loop runs until you quit.