COMPUTING
NERDS.COM
A PLACE TO LEARN PYTHON PROGRAMMING
INFINITE LOOPS



Sometimes a program can get stuck in an infinite loop. This can be through an error in the code e.g. the condition of a while loop is never met. An Example is below:



This program prompt the user input to enter either a Y or a N in response to the question. Whichever you input the program will output on screen THIS IS AN INFINITE LOOP again and again, FOREVER. This is because the print statement is inside of the while statement. This means you will only be asked to input your response once and WHILE the answer you give will not change, the program will always print out the print statement again and again and again...