Home > Article > Backend Development > How to use while loop in python
This article mainly introduces the usage of the while loop statement in python, and analyzes the use of the while statement with examples. Friends in need can refer to it
The examples in this article describe the usage of the while loop statement in python. Share it with everyone for your reference. The specific analysis is as follows:
For python’s while statement, just pay attention to its indentation. Python, like other languages, also has break and continue, which are used to indicate jumping out of the loop and continuing the loop respectively.
#!/usr/bin/python # Simple while loop a = 0 while a < 15: print a, # 在print a后面加,不换行 if a == 10: print "made it to ten!!" a = a + 1
The running results are as follows:
0 1 2 3 4 5 6 7 8 9 10 made it to ten!!
11 12 13 14
The above is the detailed content of How to use while loop in python. For more information, please follow other related articles on the PHP Chinese website!