-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (47 loc) · 1.48 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import random
from turtle import clear
from hangman_art import hang_man_arty
print(hang_man_arty)
from hangman_art import HANGMANPICS
from words import words_list
chosen_word = list(random.choice(words_list))
chosen_word_len = len(chosen_word)
# print(chosen_word)
lives = 6
display = []
for _ in range(chosen_word_len):
display.append("_")
print(display)
end_of_game = False
while not end_of_game:
guess = input("write down a letter you think is in the word").lower()
clear()
if guess in display:
print(f"you've already guessed {guess},PLEASE TRY AGAIN")
for position in range(chosen_word_len):
if chosen_word[position] == guess:
display[position] = chosen_word[position]
if guess not in chosen_word:
print(f"{guess} is what you guessed, and is not in the chosen word. So you lose a life. PLEASE TRY AGAIN")
lives-= 1
if lives == 0:
print("You Lost\n",HANGMANPICS[6])
print(chosen_word)
end_of_game = True
elif lives == 1:
print(HANGMANPICS[5])
elif lives == 2:
print(HANGMANPICS[4])
elif lives == 3:
print(HANGMANPICS[3])
elif lives == 4:
print(HANGMANPICS[2])
elif lives == 5:
print(HANGMANPICS[1])
elif lives == 6:
print(HANGMANPICS[0])
print(display)
if "_" not in display:
end_of_game = True
print("YOU WIN")
# print(HANGMANPICS[lives])