-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhangman2.0.py
More file actions
100 lines (80 loc) · 1.54 KB
/
hangman2.0.py
File metadata and controls
100 lines (80 loc) · 1.54 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import random
stages = ['''
+---+
| |
O |
/|\ |
/ \ |
|
=========''','''
+---+
| |
O |
/|\ |
/ |
|
=========''','''
+---+
| |
O |
/|\ |
|
|
=========''','''
+---+
| |
O |
/| |
|
|
=========''','''
+---+
| |
O |
| |
|
|
=========''', '''
+---+
| |
O |
|
|
|
=========''','''
+---+
| |
|
|
|
|
=========''',]
words=["apple", "house", "tiger", "phone", "brain", "smile", "river", "table", "pizza", "rainbow", "bicycle", "monster", "journey", "village", "laptop", "diamond", "curtain", "picture", "airport", "astronaut", "crocodile", "knowledge", "nightmare", "blueprint", "whispering", "avalanche", "microwave", "rectangle", "volcano" ]
Random_word=random.choice(words)
print(Random_word)
for letters in range(len(Random_word)):
print("_", end="")
game_over = False
container = []
lives=6
while not game_over:
display = ""
guess = input("\nGuess a letter: ")
if guess not in container:
container.append(guess)
if guess not in Random_word:
lives-=1
print(stages[lives])
for i in range(len(Random_word)):
if guess==Random_word[i]:
print(guess,end="")
display+=guess
elif Random_word[i] in container:
print(Random_word[i],end="")
else:
print("_",end="")
display+="_"
if "_" not in display:
game_over = True
if lives==0:
game_over=True