Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Future Learn / Logic & Maths / Guessing Game
- import random
- secret = random.randint(1,50)
- #print("Secret number is ", secret)
- guess = 0
- tries = 0
- print("Guess a number between 1 and 50 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")
- if tries==5 and guess!=secret:
- print("You are out of tries")
- print("You did not guess the secret number")
- print("The secret number is ", secret)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement