猜年龄限制次数,使用while函数和count计数器。

age_of_spencer = 28
count = 0
while True:
    if count == 2:
        break
    age = int(input("age:"))
    if age == age_of_spencer:
        print("you made it")
        break
    elif age >= age_of_spencer:
        print("too big")
    else:
        print("too small")
    count = count + 1
if count==2:
    print("you had tried too many times")

 

相关文章:

  • 2021-10-14
  • 2022-01-24
  • 2021-06-05
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-20
  • 2021-08-02
  • 2021-09-25
  • 2022-03-06
  • 2022-12-23
  • 2022-01-10
相关资源
相似解决方案