-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_cw5_06_gallow.py
More file actions
82 lines (60 loc) · 1.6 KB
/
main_cw5_06_gallow.py
File metadata and controls
82 lines (60 loc) · 1.6 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
# import re
word = ["banana", "borsch", "milk", "apple", "pine", "salo", "sushi"]
"""
------
| |
|
/ \\
"""
gallows = [["-", "-", "-", "-", "-", "-"],
[" ", "|", " ", " ", "|", " "],
[" ", "|", " ", " ", " ", " "],
[" ", "|", " ", " ", " ", " "],
[" ", "|", " ", " ", " ", " "],
["/", " ", "\\", " ", " ", " "],]
def draw_gallows(step=None):
if step:
if step >= 1:
gallows[2][4] = "O"
if step >= 2:
gallows[3][3] = "/"
if step >= 3:
gallows[3][4] = "|"
if step >= 4:
gallows[3][5] = "\\"
if step >= 5:
gallows[4][3] = "/"
if step >= 6:
gallows[4][5] = "\\"
result = ""
for i in gallows:
result += "".join(i) + "\n"
return result
def main():
# for i in range(0, 6+1):
step = 0
print(draw_gallows())
word = "hello"
answer_word = ["_" for _ in range(len(word))]
print((len("Hello") * " _ ").strip())
while True:
user_input = input("Give yuor letter >>>")
if user_input == "":
break
if user_input not in word:
step += 1
print(draw_gallows(step + 1))
else:
# indexes_letter = re.findall(user_input, word)
answer_word[index_letter] = user_input
print(" ".join(answer_word))
if __name__ == "__main__":
main()
# gallows[2][4] = "O"
# gallows[3][3] = "/"
# gallows[3][4] = "|"
# gallows[3][5] = "\\"
# result = ""
# for i in gallows:
# result += "".join(i) + "\n"
# print(result)