Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- secnum = random.randint(1, 10) #Generates a random number 1-10 and assigns value to x
- print(secnum)
- print()
- print("I'm thinking of an integer in the range 1 to 10. You have three guesses.")
- print()
- for i in range(3):
- for x in ["first", "second", "third"]:
- guess = int(input("Enter your " + str(x) + " guess: "))
- if i < 3 and guess > secnum:
- print("Your guess is too high.")
- elif i < 3 and guess < secnum:
- print("Your guess is too low.")
- elif i < 3 and guess == secnum:
- print("You win!")
- else:
- print("You lose. The number was " + str(secnum) +".")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement