Tuesday, February 8, 2011

Infinite loops

Today working on the Example of python3 I found an interesting command which was Infinite loops.
 This is the command:
while 1 == 1:
    print("Help, I am stuck in a loop.")



This command will keep  printing "Help, I am stuck in a loop." because 1 is equal to 1, thats the first command where it said (while 1 == 1), then there was no way to stop it after I run it but I read the tutorial and found that with (Ctrl + c) this command will stop.

I am getting more interesting in Python.

 



1 comment:

  1. while True: will also work, or while 'henry' == 'henry'

    Of course, you don't usually want an infinite loop! ;-)

    ReplyDelete