Python--循环练习

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Huanglinsheng

for i in range(10):
    if i < 5:
        continue  #不往下走了,直接进入下一次loop
    print("loop:",i)


for i in range(10):
    if i > 5:
        break  #不往下走了,直接跳出整个loop
    print("loop:",i)


count = 0
while True:
    print("I love you forever!")
    count += 1
    if count == 5:
        print("nothing!!")
        break
else:
    print("=========================")

i = 0
while i<=3:
    print("Python is so easy!")
    i += 1
else:
    print("============11=============")

 

posted on 2018-07-23 16:54  huanglinsheng  阅读(96)  评论(0编辑  收藏  举报

导航