python之路-day1-while循环
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python之路-day1-while循环相关的知识,希望对你有一定的参考价值。
while Thue: (条件为真无限循环) break(跳出循环)
猜年龄:
#Author:zww
age_of_jay = 40
count = 0
while count < 3:
guess_age = int(input("guess_age:"))
if guess_age > age_of_jay:
print("think smaller...")
elif guess_age < age_of_jay:
print("think bigger...")
else:
print("yes,you got it!")
break
count +=1
if count == 3:
conutine_confirm = input("do you want to keep guessing...?")
if conutine_confirm != "n":
count = 0
else:
print("you have tried too many times...fuck off")
以上是关于python之路-day1-while循环的主要内容,如果未能解决你的问题,请参考以下文章