法一:
#!/usr/bin/env python
#_*_ coding:utf-8 _*_
for i in range(0,10,2): #步长值为2
print("loop",i)
法二:
#!/usr/bin/env python
#_*_ coding:utf-8 _*_
for i in range(0,10):
if i < 3 :
print("loop",i)
else:
continue #终止小循环
print("hehe...")
法三:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
age_of_jack = 23
for i in range(3):
guess_age = int(input('guess age:'))
if guess_age == age_of_jack:
print('yes,you got it.')
break
elif guess_age > age_of_jack:
print('think smaller...')
else:
print('think bigger!')
else:
print('you have tried too many times,fuck off')
法四:
#!/usr/bin/env python
#_*_ coding:utf-8 _*_
for i in range(10):
print('----',i)
for j in range(10):
print(j)