Infinite Loops
tags: #python/documentation/python_loops
What are Infinite Loops?
An infinite loop in Python is a continuous repetitive conditional loop that gets executed until an external factor interferes in the flow of execution.
This occurs when the boolean expression in a while loop never evaluates to False. When the condition is always True, we get an infinite loop.
Example:
a = 1
while a==1:
b = input('What is your name?')
print('Hi', b, ', Welcome!')
Use Case
We can still use this pattern to build useful loops as long as we carefully add code to the body of the loop to explicitly tell Python to exit the loop using the break keyword when we have reached the exit condition.