Tom_Jung

Untitled

Apr 11th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import random
  2. secret = random.randint(1,20)
  3. #print("Secret number is ", secret)
  4.  
  5. guess = 0
  6. tries = 0
  7.  
  8. print("Guess a number between 1 and 20 in five tries.")
  9.  
  10. while (guess!=secret) and (tries<5):
  11.  
  12. guess = int(input("Enter your guess: "))
  13.  
  14. tries = tries + 1
  15. print("Tries = ", tries)
  16.  
  17. if guess == secret:
  18. print("Yeah, you got it!")
  19. elif guess < secret:
  20. print("Your guess it too low")
  21. elif guess > secret:
  22. print("your guess is too high")
  23.  
  24. if tries==5 and guess!=secret:
  25. print("You are out of tries")
  26. print("You did not guess the secret number")
  27. print("The secret number is ", secret)
Advertisement
Add Comment
Please, Sign In to add comment