Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. import random
  2.  
  3. secnum = random.randint(1, 10) #Generates a random number 1-10 and assigns value to x
  4. print(secnum)
  5. print()
  6. print("I'm thinking of an integer in the range 1 to 10. You have three guesses.")
  7. print()
  8.  
  9. for i in range(3):
  10.     for x in ["first", "second", "third"]:
  11.         guess = int(input("Enter your " + str(x) + " guess: "))
  12.         if i < 3 and guess > secnum:
  13.             print("Your guess is too high.")
  14.         elif i < 3 and guess < secnum:
  15.             print("Your guess is too low.")
  16.         elif i < 3 and guess == secnum:
  17.             print("You win!")
  18.         else:
  19.             print("You lose. The number was " + str(secnum) +".")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement