python for循环基础实例

1、for循环竞猜年龄:

age_of_oldboy = 56

#guess_age = int(input("guess age:"))

count = 0
for i in range(3):
guess_age = int(input("guess age:"))
if guess_age == age_of_oldboy :
print("yes, you got it. ")
break #结束循环
elif guess_age > age_of_oldboy:
print("think smaller...")
else:
print("think bigger!")
else:
print("you have tried too many times.. fuck off..")

2、for循环,continue跳出本次循环
for i in range(0,10):
if i < 3:
print("loop",i)
else:
continue #跳出本次循环,进入下次循环
print("hehe...")
posted @ 2018-04-24 19:05  无所住心  阅读(755)  评论(0编辑  收藏  举报