Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import random
  2. x = random.randint(1, 20)
  3. print('Im thinking of a number between 1 and 20')
  4. for i in range(1, 4):
  5. print('Take a guess')
  6. y = int(input())
  7. if y > x:
  8. print('Your guess is too high.')
  9. elif y < x:
  10. print('Your guess is too low.')
  11. else:
  12. break
  13. i += 1
  14. if y == x:
  15. print('Good job! You guessed my number in', i, end = ' ')
  16. if i == 1:
  17. print('guess.')
  18. else:
  19. print('guesses.')
  20. else:
  21. print("My number was actually " + str(x) + '.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement