Python循环语句

1.while 语句

while  条件1:  
   操作1
#先判断条件1
#再执行操作1

例如:
#死循环
while  1==1:
     print('OK')
   

 联系题:

1.输出 1 2 3 4 5 6   8 9 10

1 a = 1
2 while a<11
3     if a!=7
4         print (a)
5     print(" ")
6    a = a+1

2.求 1-100所有数的总和

1 a=1
2 b=0
3 while a<=100
4     b = b+a
5     a = a+1
6 print(b)

 continue 终止当前循环

 break 终止中循环(跳出循环)

原文地址:https://www.cnblogs.com/goodgoodstudy2018/p/11264952.html