Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- x = random.randint(1, 20)
- print('Im thinking of a number between 1 and 20')
- for i in range(1, 4):
- print('Take a guess')
- y = int(input())
- if y > x:
- print('Your guess is too high.')
- elif y < x:
- print('Your guess is too low.')
- else:
- break
- i += 1
- if y == x:
- print('Good job! You guessed my number in', i, end = ' ')
- if i == 1:
- print('guess.')
- else:
- print('guesses.')
- else:
- print("My number was actually " + str(x) + '.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement