Python_No.5 while循环

# !/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Hugolinhj

count = 0


age_of_oldboy = 56
count = 0
while count <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!")
count +=1 #count数值+1
else:
print ("you have tried too many time.. fuck off")


############################################################33
age_of_oldboy = 56
count = 0
while count < 3:
=== while True:
    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 #count数值+1
   if count ==3:
break
else:
print ("you have tried too many time.. fuck off")


############################################
age_of_oldboy = 56
count = 0
while count <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...")
count -=1
else:
print("think bigger!")
count +=1
if count ==3:
countine_confirm = input("do you want to keep guessing?")
if countine_confirm != 'n': #不等于字符"n"
count =0
else:
print ("you have tried too many time.. fuck off")


"""
if count ==3:
countine_confirm = input("do you want to keep guessing?")
if countine_confirm != 'n': #不等于字符"n"
count =0

重置count为0
"""
"""
break #退出
!= #不等于
"""
posted @ 2020-12-03 23:11  命由我  阅读(93)  评论(0编辑  收藏  举报