Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- secret = random.randint(1,10)
- print("Secret number is ", secret)
- guess = 0
- tries = 0
- print("Guess a number between 1 and 10 in five tries.")
- while (guess!=secret) and (tries<5):
- guess = int(input("Enter your guess: "))
- tries = tries + 1
- print("Tries = ", tries)
- if guess == secret:
- print("Yeah, you got it!")
- elif guess < secret:
- print("Your guess it too low")
- elif guess > secret:
- print("your guess is too high")
- elif tries == 5:
- print("Sorry, you are out of tries.")
- else:
- print("You didn't guess the secret number")
- if guess!=secret:
- print("The secret number was", secret)
Advertisement
Add Comment
Please, Sign In to add comment