This commit is contained in:
Виталий Туров 2025-01-25 09:12:29 +03:00
parent 4f27039be2
commit d4b298d56a

View File

@ -1 +1,84 @@
print("Hello, World!") import random
word_dict = {
"питон": "интерпритируемый язык программирования",
"голанг": "компилируемый язык программирования",
}
def game():
word_number = random.randint(0, len(word_dict) - 1)
word = list(word_dict.keys())[word_number]
describe = word_dict[word]
guess = ['_' for _ in word]
value_guess = len(word)
print(describe)
print(" ".join(guess))
while value_guess > 0:
character = input("Введите букву: ")
if word.count(character) >= 1:
for index, value in enumerate(word):
if character == value:
guess[index] = value
else:
value_guess -= 1
print(f"У вас осталось {value_guess} попыток")
if guess.count('_') == 0:
print(" ".join(guess))
break
print(" ".join(guess))
else:
print(f"GAME OVER =(")
def run_game():
game()
def save_game():
pass
def load_game():
pass
def exit_game():
exit(0)
def menu():
print(
"""
1. Начать игру
2. Сохранить
3. Загрузить
4. Выход
"""
)
def read_selector():
key = int(input(":"))
match key:
case 1:
run_game()
case 2:
save_game()
case 3:
load_game()
case 4:
exit_game()
def main():
menu()
read_selector()
if __name__ == "__main__":
main()