Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def guessing_game():
- print("""
- welcome to the guessing game
- this is the rules:
- think on a number between 1 - 100
- after every guess wright
- yes - if this is your number
- bigger - if your number is bigger
- smaller - if your number is smaller
- exit - for exit the game
- """)
- bigger_than = 0
- smaller_than = 100
- try:
- while True:
- number = random.randint(40, 60)
- ans = input(f'your number is {number}? ').lower()
- if 'smaller' in ans or 'small' in ans:
- smaller_than = number - 1
- number = random.randint(bigger_than, smaller_than)
- elif 'bigger' in ans or 'big' in ans:
- bigger_than = number + 1
- number = random.randint(bigger_than, smaller_than)
- elif 'no' in ans:
- print('wright if bigger or smaller')
- else:
- if 'yes' in ans:
- print('I win!')
- break
- elif 'exit' in ans:
- print('bye bye')
- break
- else:
- print('wrong value')
- except ValueError:
- print('you are a liar!')
- guessing_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement