猜年龄小游戏

age_old_boy = 56
guess_age = int(input("guess age:"))

if guess_age == age_old_boy:
    print("Yes, you got it.")
elif guess_age > age_old_boy:
    print("think smaller...")
else:
    print("think biger...")


#循环版本:

age_old_boy = 56

count = 0

while count<3://for i in range(3):   (不用count计数)

    guess_age = int(input("guess age:"))

    if guess_age == age_old_boy:

          print("Yes,you got it.")

    elif guess_age < age_old_boy:

          print("think biger...")

    else:

          print("think smaller...")

    count += 1

    if count == 3:

          continue_confirm = input("do you want to keep guessing...?")

          if continue_confirm == 'n':

              count = 0

#else:

    #print("you have tried too many times...")

猜你喜欢

转载自blog.csdn.net/RoundOff/article/details/87903649