#for循环 for-else语句
for name in ['zhangsan','lisi','wangwu','doudou','huahua']:
print (name)
if name == 'doudou':
print ("{0} is a good boy!".format(name))
else:
print ('继续加油!')
else:
print('哈哈哈哈')
----------------------------------------
for i in range(1,10):
#一般在Python中表示范围的两个数字包含左边数字,不包含右边数字,randint都包括
print(i)
-------------------------------------------------
#break,结束整个循环
#continue,结束本次循环,进入下一轮循环
#pass,略过,经常用于占位
#寻找数字8
for i in range(1,10):
if i == 8:
print('找到{0}了'.format(i))
break
else:
print(i)
#寻找数字8
for i in range(1,10):
if i == 8:
print('找到{0}了'.format(i))
continue
else:
print(i)
for i in range(1,10):
pass