Advertisement
Kamarbandi

find random number

Feb 25th, 2020
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import random
  2. reqem = random.randint(0, 100)
  3.  
  4. def checkIt(prompt):
  5.     counter = 0
  6.  
  7.     while True:
  8.         try:
  9.             value = int(input(prompt))
  10.         except ValueError:
  11.             print("Sorry, I didn't understand that.")
  12.             continue
  13.  
  14.         if value == reqem:
  15.             counter += 1
  16.             print(f'* Tebrikler!!! Siz ' + str(counter) + ' cehd ile qalib oldunuz *')
  17.             break
  18.         elif value < reqem:
  19.             counter += 1
  20.             print('-- Coxalt --')
  21.             continue
  22.         elif value > reqem:
  23.             counter += 1
  24.             print('-- Azalt -- ')
  25.             continue
  26.  
  27.         elif value < 0:
  28.             counter += 1
  29.             print("Sorry, your response must not be negative.")
  30.             continue
  31.  
  32.     return value
  33.  
  34. checkIt(' 0 ile 100 arasi reqem secin')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement