The python loop (while statement)

loop statement

loop statement Explanation
while If it is true, the loop is often used with comparison operators
for If it is true, the loop is often used with the operator member
continue Terminate the current cycle, the next cycle
break Exit the loop, execute the next command

while statements can be very simple to create an infinite loop

while True:
    print("循环")

Here Insert Picture Description
Of course, you can exit the loop through the break, such as:

while  True:								# while 即 若 i 是True
    i=input("请输出0退出")		# 输入
    if i=='0':					# 默认输入的0是字符串,要转换成整形0
        break				    # break退出循环

Guess you like

Origin blog.csdn.net/GrofChen/article/details/91374709