-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhangman.py
More file actions
62 lines (55 loc) · 1.57 KB
/
hangman.py
File metadata and controls
62 lines (55 loc) · 1.57 KB
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
59
60
61
62
# Hangman in Python
import random
words = ("apple", "banana", "orange", "pear", "watermelon")
hangman_art = {0: (" ",
" ",
" "),
1: (" o ",
" ",
" ",
" "),
2: (" o ",
" | ",
" ",
" "),
3: (" o ",
" /| ",
" ",
" "),
4: (" o ",
" /|\\ ",
" ",
" "),
5: (" o ",
" /|\\ ",
" / ",
" "),
6: (" o ",
" /|\\ ",
" / \\ ",
" ")
}
def display_man(wrong_guesses):
for line in hangman_art[wrong_guesses]:
print(line)
print(hangman_art[wrong_guesses])
def display_hint(hint):
pass
def display_answer(answer):
pass
def main():
answer = random.choice(words)
hint = ["_"] * len(answer)
wrong_guesses = 0
guessed_letters = set()
is_running = False
while is_running:
display_man(wrong_guesses)
display_hint(hint)
display_answer(answer)
guess = input("Guess a letter: ").lower()
if guess in guessed_letters:
print("You already guessed that letter.")
continue
if __name__ == "__main__":
main()