Advertisement
Rementai

Guessing game Pyton

Mar 2nd, 2023 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. import random
  2.  
  3. number = random.randint(1,10)
  4. counter = 0
  5.  
  6. while True:
  7.     guess = int(input("Guess a number 1-10: "))
  8.     counter += 1
  9.     if guess > number:
  10.         print("Too high")
  11.     elif guess < number:
  12.         print("Too low")
  13.     else:
  14.         print("Yes! You found the number!")
  15.         break
  16.     if counter > 2:
  17.         print("Unlucky, you lose!")
  18.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement