Advertisement
BojidarDosev

rand num guesser

Apr 28th, 2025
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import random
  2.  
  3. num = random.randint(1,100)
  4. userinp = int(input("Enter a number between 1 and 100: "))
  5. br = 1;
  6. while userinp != num:
  7.     br=br+1
  8.     if userinp > num:
  9.         print("Too big")
  10.     elif userinp < num:
  11.         print("Too small")
  12.     userinp = int(input("Enter a number between 1 and 100: "))
  13.  
  14. print("You guessed it! The number was", num)
  15. print("It took you " , br , " tries!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement