Python while Loop statement
While loop statement syntax
while expression: statement(s)
groups of the statement while a condition is true
run = 0 while (run < 0) : print 'the run is:', run run = run +1 print "thanks!"
Note: when the above code excute the result will be
The run is: 0 The run is: 1 The run is: 2 The run is: 3 The run is: 4 thanks!
terminated the loop current iteration, and continue with the start immediately .
It's used in both while and for loops.
#!/usr/bin/python for letter control in #first example if letter == 't': continue print 'Current Letter :', letter
i = 0 while i < 4: #second example i += 1 if i == 1: continue print(i)
#first result Current Letter : c Current Letter : o Current Letter : n Current Letter : r Current Letter : o Current Letter : l
#second result 2 3 4