13 March 2014

Python: How to Create an Infinite Loop

This tutorial contains the code for creating an infinite loop program in Python. It keeps printing the same output forever. I don't know if this would technically be a loop, but people will find it this way, and that's all that matters.

def thing():
x = 1
while x == 1:
print 'hello'
  1. Write the above code in the Python shell.
  2. Press enter several times to confirm the code.
  3. Write thing() and press enter.
  4. The program will print 'hello' forever, or until your computer dies.