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循环的主要内容,如果未能解决你的问题,请参考以下文章

Python之路-条件控制与循环语句

python修炼之路-day2

python基础成长之路四-基础数据类型方法

python之路之前没搞明白4面向对象(封装)

Python工程师Java之路(u)Java循环输入

Python工程师Java之路(u)Java循环输入