Tom_Jung

Untitled

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