标签:ldb big 简洁 == guess int 跳出循环 else conf
示例:
age_of_oldboy = 56
count = 0 while True:
if count == 3:
#只能尝试三次
break
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!")
count += 1
示例2:
标签:ldb big 简洁 == guess int 跳出循环 else conf
原文地址:http://www.cnblogs.com/FutureStar/p/7657117.html