-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhangman_game.py
32 lines (24 loc) · 1.06 KB
/
hangman_game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import random
all_words = ["apple", "computer", "tv", "bike", "game", "greeting", "magic", "roof", "fish", "orange", "laptop", "love"]
current_word = f"{all_words[random.randint(0, len(all_words) - 1)]}"
len_current_word = len(current_word)
sum_of_latter = ""
print("Hangman - GAME")
print(f"First latter of the word: {current_word[0]}, the last latter {current_word[-1]}")
while True:
answer_latter = input("Enter your latter: ").lower()[0]
if answer_latter in current_word:
sum_of_latter += answer_latter
len_current_word -= 1
print(f"Lucky! Gussed right latter - {answer_latter.upper()}! Left latters {len_current_word}!")
else:
print("Try again!")
if sum_of_latter == current_word:
print("YOU ARE WIN!")
elif set(sum_of_latter) == set(current_word):
print("YOU GUSSED ALl! REPLACE THE LATTERS!")
answer_word = input("Enter the word: ").lower()
if answer_word == current_word:
print("YOU ARE WIN!")
else:
print("You are lose!")