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