johnpentyrch

math28

Feb 20th, 2022 (edited)
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import random
  2. secret = random.randint(1,20)
  3. ##print('secret ',secret)
  4. guess = 0
  5. tries = 0
  6. print('Try to guess a number between 1 and 20, using the four clues if you need them.')
  7. print('You have 5 guesses.')
  8. while (guess != secret) and (tries < 5):
  9.     guess = int(input('What is your guess? '))
  10.     tries = tries + 1
  11.     if guess == secret:
  12.         print('You got it')
  13.  
  14. if guess != secret:    
  15.     print ('Wrong, sorry, you have used up your five guesses. Better luck next time.')
  16.     print ('The secret number was', secret)
  17.  
  18.  
  19.  
Add Comment
Please, Sign In to add comment