猜年龄

oldboy_age = 5

guess_age = int(input("guess your answer:"))

if guess_age == oldboy_age:

   print("you got it!")

   break

elif guess_age > oldboy_age:

   print("please think smaller")

else:

   print(:please think bigger")

 

限制次数的:(while形式)

count = 0

while count <3:

    guess_age = int(input("guess your answer:"))

    if guess_age == oldboy_age:

        print("you got it!")

        break

    elif guess_age > oldboy_age:

        print("please think smaller")

    else:

        print(:please think bigger")

    count +=1

限制次数:(for形式)

oldboyage = 56
count = 0
for i in range(3):
guess_age = int(input("please guess her age:"))
if guess_age == oldboyage:
print("you got it! fuck me!")
break
elif guess_age > 56:
print("think smaller")
else:
print("think bigger")
count += 1

任性玩:
oldboy_age = 56
count = 0
while count < 3:
guess_age = int(input("please guess her age:"))
if guess_age == oldboy_age:
print("you got it! fuck me!")
break
elif guess_age > 56:
print("think smaller")
else:
print("think bigger")
count += 1
if count == 3:
continue_confirm = input("Do you want to go on?")
if continue_confirm != "n":
count = 0
 
posted @ 2018-02-12 23:18  亚格斯123  阅读(189)  评论(0编辑  收藏  举报