Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import random
  2. secret = random.randint(1,20)
  3. guess = 0
  4. tries = 0
  5. print('Try to guess a number between 1 and 20, using the four clues if you need them, You have 5 guesses')
  6. while (guess!=secret) and (tries<5):
  7. guess = int(input ('What is your guess? '))
  8. tries = tries + 1
  9. if guess == secret:
  10. print('You got it')
  11. elif guess < secret:
  12. print('clue n. ‘,tries,‘ your guess is too low, try again')
  13. elif guess > secret:
  14. print('clue n. ‘,tries,‘ your guess is too high, try again')
  15. if guess!=secret:
  16. print ('Wrong, sorry, you have used up your five guesses. Better luck next time.')
  17. print ('The secret number was',secret)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement