While loops

--Originally published at Programming Fundaments

The “while” statement that repeatedly executes a certain statement as long as a given statement is true

while expression:
   statement(s)

The while loop, is that the loop might not ever run. When the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed.

Andddd you can create and infinite loop by creating a condition that is never “false”. This is often used by client/server programming, because it needs to run always. Example:

var = 1
while var == 1 :  # This constructs an infinite loop
   num = raw_input("Enter a number  :")
   print "You entered: ", num