Advertisement
Guest User

AHUEVO!

a guest
Feb 18th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. print("Hello!, this game is called 'Magic Number', all you have to do is guess my magic number, which is from 25-368. \n
  2.       Do you want to guess? (yes/no)")
  3. answer = input()
  4. number = 76
  5.  
  6.  
  7. # Setting up string to lowercase for easy comparing.
  8. answer.lower()
  9.  
  10. guessing = False
  11.  
  12. if answer == "yes":
  13.     print("Cool, let's start!")
  14.     guessing = True
  15. elif answer == "no":
  16.     print("Goodbye!")
  17. else:
  18.     print("Sorry, I didn't quite catch that. Refresh and try again.")
  19.  
  20.  
  21. while guessing:
  22.     print("Take a guess, but if you want to stop just type 'exit'.")
  23.     answer = input()
  24.    
  25.     if answer.isdigit():
  26.         if int(answer) > num:
  27.             print("Oops! Your number is too high")
  28.         elif int(answer) < num:
  29.             print("Oops! Your number is too low")
  30.         elif int(answer) == num:
  31.             print("You won! 76 is the correct number, thanks for playing!")
  32.             guessing = False
  33.    
  34.     elif answer = "exit":
  35.         guessing = False
  36.    
  37.     else:
  38.         print("Sorry, I didn't catch that, try again.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement