Advertisement
Guest User

eshel guessing game new

a guest
Apr 8th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def guessing_game():
  5.     print("""
  6. welcome to the guessing game
  7. this is the rules:
  8. think on a number between 1 - 100
  9. after every guess wright
  10. yes - if this is your number
  11. bigger - if your number is bigger
  12. smaller - if your number is smaller
  13. exit - for exit the game
  14.          """)
  15.     bigger_than = 0
  16.     smaller_than = 100
  17.     try:
  18.         while True:
  19.             number = random.randint(40, 60)
  20.             ans = input(f'your number is {number}? ').lower()
  21.             if 'smaller' in ans or 'small' in ans:
  22.                 smaller_than = number - 1
  23.                 number = random.randint(bigger_than, smaller_than)
  24.             elif 'bigger' in ans or 'big' in ans:
  25.                 bigger_than = number + 1
  26.                 number = random.randint(bigger_than, smaller_than)
  27.             elif 'no' in ans:
  28.                 print('wright if bigger or smaller')
  29.             else:
  30.                 if 'yes' in ans:
  31.                     print('I win!')
  32.                     break
  33.                 elif 'exit' in ans:
  34.                     print('bye bye')
  35.                     break
  36.                 else:
  37.                     print('wrong value')
  38.     except ValueError:
  39.         print('you are a liar!')
  40.  
  41.  
  42. guessing_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement