Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- n = random.randint(1, 100)
- guess = int(input("Enter a number between 1 and 100: "))
- guessnum = 0
- while n != guess:
- guessnum = guessnum + 1
- if guess < n:
- print ("Too Low.")
- guess = int(input("Enter a number between 1 and 100: "))
- elif guess > n:
- print ("Too high.")
- guess = int(input("Enter a number between 1 and 100: "))
- else:
- print ("Correct!")
- break
- if guess == n:
- guessnum = str(guessnum)
- print("It took you this many guesses: " + guessnum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement