标签:
学习关于break和continue的使用
1.使用while,输出从a到b的所有数字
# print all numbers from a to b a = 5 b = 10 while True: if a >= b: print a break else: print a a += 1 print "Test is over."
# print all numbers from a to b a = 5 b = 10 while a <= b: print a a += 1 print "Test is over."
用for循环实现
a = 5 b = 10 for a in range(a, b + 1, 1): print a a += 1 print "Test is over."
# print all numbers from a to b a = 5 b = range(5, 11, 1) for a in b: print a a += 1 print "Test is over."
2.continue
退出当前循环,进入下一个循环
to be continued
标签:
原文地址:http://www.cnblogs.com/nopear/p/5762267.html