import random, easygui
secret = random.randint(1, 99)
guess = 0
tries = 0
easygui.msgbox("""Hi! I'm the Dread Pirate Roberts, and I have a secret!
It is a number from 1 to 99. I'll give you 6 tries...""")
while guess != secret and tries < 6:
guess = easygui.integerbox("what's your guess?")
if not guess: break
if guess < secret:
easygui.msgbox(str(guess) + "is too low!")
elif guess > secret:
easygui.msgbox(str(guess) + "is too high!")
tries += 1
if guess == secret:
easygui.msgbox("Great! You got it! Found my secret, you did!")
else:
easygui.msgbox("No more guesses! The number was" + str(secret))

相关文章:

  • 2022-12-23
  • 2021-11-10
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
猜你喜欢
  • 2023-03-30
  • 2021-09-11
  • 2021-10-15
  • 2022-02-16
  • 2022-01-26
  • 2021-05-07
相关资源
相似解决方案