Infinite Loops

Carson West

While Loops

Infinite Loops

An infinite loop is a loop that never terminates, meaning it continues to execute indefinitely. This usually happens due to a logical error in the loop’s condition. It can freeze your program and require manual intervention (like pressing Ctrl+C) to stop it.

Causes:

Debugging:

Example of a corrected loop:

i = 0
while i < 10:
    print(i)
    i += 1  # Correct increment

Prevention:

Loop Control Statements