Advertisement
earlution

Number guessing game v0.1

Jun 12th, 2020
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import random
  2.  
  3. random_number = random.randint(1,100)
  4. guess = int(input("Guess a number between 1 and 100: "))
  5. attempts = 1
  6.  
  7. while guess != random_number:
  8.     attempts += 1
  9.     if guess > random_number:
  10.         guess = int(input("lower: "))
  11.     elif guess < random_number:
  12.         guess = int(input("higher: "))
  13.  
  14. print("Well done!")
  15. print("You guessed the random number in",  attempts, "attempts.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement