Advertisement
Capple

Untitled

Jun 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. from random import randint
  2.  
  3. jrk = int(input("How many chances do you want to guess the number??"))
  4. arv = randint(1, 10)
  5. guess = int(input("You have " + str(jrk) + " guesses! Think of a number betwen 1-10: "))
  6.  
  7. while jrk != 0:
  8.    
  9.     if arv > guess:
  10.         jrk -= 1
  11.         guess = int(input("You have " + str(jrk) + " chances left. The searchable number is bigger. Try again:"))
  12.  
  13.     elif arv < guess:
  14.         jrk -= 1
  15.         guess = int(input("You have " + str(jrk) + " chances left. The searhable number is smaller. Try again:"))
  16.     if guess == arv:
  17.         print("You won.")
  18.         break
  19.     if jrk == 0:
  20.         print("You lost. The number was " + str(arv))
  21.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement