commit 2b90bb8f3a20af5206c910823ba21ddb8138e467 Author: User Date: Wed Apr 30 19:30:02 2025 +0300 Create alfa-version game diff --git a/Short_plan b/Short_plan new file mode 100644 index 0000000..5c77435 --- /dev/null +++ b/Short_plan @@ -0,0 +1,13 @@ +№1 Короткий план + +1) Задать значения максимального количества попыток и количества символов в одной попытке + +2) Вывод условия игры + +3) Создание случайного числа + +4) Создание основного цикла while для завершения или повторения игры + +5) Создание цикла while для ввода попыток + +6) Создание цикла while для анализа попытки и вывода подсказки diff --git a/main.py b/main.py new file mode 100644 index 0000000..8501999 --- /dev/null +++ b/main.py @@ -0,0 +1,48 @@ +import random + + +max_nam = 10 +guess_num = 3 +digits = "0123456789" + +while True: + digits = list(digits) + random.shuffle(digits) + secret_num = '' + for i in digits[0:3]: + secret_num += i + + print("I mean digit.") + attemt_num = 1 + + + while max_nam >= attemt_num: + attemt = '' + while len(attemt) != guess_num or not attemt.isdecimal(): + print(f"Attemt № {attemt_num}") + attemt = input("> ") + + clue = [] + + if secret_num == attemt: + print("You win!") + break + + for i in range(len(attemt)): + + if secret_num[i] == attemt[i]: + clue.append("Fermi") + if attemt[i] in secret_num: + clue.append("Pico") + if len(clue) == 0: + print("Bagle") + else: + sorted(clue) + print(' '.join(clue)) + attemt_num += 1 + print("You spent your attemt") + print(f"You want repit the game. The hiden numbers is {secret_num}? 'yes' or 'no'") + answer = input("> ") + if answer == 'no': + print("Thanks for playing") + break \ No newline at end of file