Advertisement
Guest User

Puto

a guest
Feb 17th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. # beginning the forloop
  2. looping = True
  3. num = 76 # number that is correct
  4.  
  5. # beginning the forloop by asking them if they want to guess.
  6. ans = input("Hello, this game is called 'Magic Number', all you have to do is guess my magic number, which is from 25-368. Do you want to guess?")
  7. if ans == 'yes':
  8.   print("Cool, let's start.")
  9. elif ans == 'no':
  10.   print("Okay, good-bye.")
  11.   looping = False
  12. else:
  13.   print("Sorry, I didn't quite catch that. Refresh and try again.")
  14.   looping = False
  15.    
  16.  
  17. # takes them here after answering 'yes'
  18. while looping:
  19.   print("Take a guess, but if you want to stop just type 'exit'.")
  20.   answer = input()
  21.  
  22.   # if they do not want to play anymore.
  23.   if answer == 'exit':
  24.     print('Thank you for trying!')
  25.     looping = False
  26.   elif 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.     looping = False
  32.     print("You won! 76 is the correct number, thanks for playing!")
  33.  
  34.  
  35.  
  36.  
  37. # if they type something weird.
  38.   else:
  39.     print("Sorry, I didn't catch that, try again.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement