黑猴子的家:Python while+If 限定次数判断Pass
2019-01-10 本文已影响19人
黑猴子的家
code
# Author:黑猴子
age_of_heihouzi = 18
#自定义计数器
count = 0
while count < 3:
guess_age = int(input("guess age:") )
if guess_age == age_of_heihouzi :
print("yes, you got it. ")
break
elif guess_age > age_of_heihouzi:
print("think smaller...")
else:
print("think bigger!")
count +=1
else:
print("you have tried too many times..fuck off")
运行
guess age:17
think bigger!
guess age:18
yes, you got it.