Created
July 14, 2020 08:39
-
-
Save KatUser/2381e56ab7d3da294caebb99d42e1416 to your computer and use it in GitHub Desktop.
Guessing Game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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