Skip to content

Instantly share code, notes, and snippets.

@KatUser
Created July 14, 2020 08:39
Show Gist options
  • Save KatUser/2381e56ab7d3da294caebb99d42e1416 to your computer and use it in GitHub Desktop.
Save KatUser/2381e56ab7d3da294caebb99d42e1416 to your computer and use it in GitHub Desktop.
Guessing Game
import random
z = random.randint(1,100)
print('Добро пожаловать в числовую угадайку!\nПожалуйста,введите число ниже:')
counter = 0
while True:
n = input()
def check():
if int(n) < z:
print(f'Ваше число меньше загаданного, попробуйте еще разок')
elif int(n) > z:
print(f'Ваше число больше загаданного, попробуйте еще разок')
def is_valid(n):
if n.isdigit() and len(n) < 3 and int(n) > 0:
check()
else:
print('А может быть все-таки введем целое число от 1 до 100?')
is_valid(n)
counter += 1
if int(n) == int(z):
break
print(f'Вы угадали! Попыток: {counter}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment