質問編集履歴
1
スペースの表示
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,75 +12,75 @@
|
|
12
12
|
|
13
13
|
def hangman(word):
|
14
14
|
|
15
|
-
|
15
|
+
,,,,wrong = 0
|
16
16
|
|
17
|
-
|
17
|
+
,,,,stages = ["",
|
18
18
|
|
19
|
-
|
19
|
+
,,,,,,,,,,,,"__________ ",
|
20
20
|
|
21
|
-
|
21
|
+
,,,,,,,,,,,,"| ",
|
22
22
|
|
23
|
-
|
23
|
+
,,,,,,,,,,,,"| | ",
|
24
24
|
|
25
|
-
|
25
|
+
,,,,,,,,,,,,"| O ",
|
26
26
|
|
27
|
-
|
27
|
+
,,,,,,,,,,,,"| /|\ ",
|
28
28
|
|
29
|
-
|
29
|
+
,,,,,,,,,,,,"| / \ ",
|
30
30
|
|
31
|
-
|
31
|
+
,,,,,,,,,,,,"| ",
|
32
32
|
|
33
|
-
|
33
|
+
,,,,,,,,,,,,]
|
34
34
|
|
35
|
-
|
35
|
+
,,,,rletters = list(word)
|
36
36
|
|
37
|
-
|
37
|
+
,,,,board = ["_"] * len(word)
|
38
38
|
|
39
|
-
|
39
|
+
,,,,win = False
|
40
40
|
|
41
|
-
|
41
|
+
,,,,print("ハングマンへようこそ")
|
42
42
|
|
43
|
-
|
43
|
+
,,,,while wrong < len(stages) - 1:
|
44
44
|
|
45
|
-
|
45
|
+
,,,,,,,,print("\n")
|
46
46
|
|
47
|
-
|
47
|
+
,,,,,,,,msg = "1文字を予想してね"
|
48
48
|
|
49
|
-
|
49
|
+
,,,,,,,,char = input(msg)
|
50
50
|
|
51
|
-
|
51
|
+
,,,,if char in rletters:
|
52
52
|
|
53
|
-
|
53
|
+
,,,,,,,,cind = rletters.index(char)
|
54
54
|
|
55
|
-
|
55
|
+
,,,,,,,,board[cind] = char
|
56
56
|
|
57
|
-
|
57
|
+
,,,,,,,,rletters[cind] = '$'
|
58
58
|
|
59
|
-
|
59
|
+
,,,,else:
|
60
60
|
|
61
|
-
|
61
|
+
,,,,,,,,wrong += 1
|
62
62
|
|
63
|
-
|
63
|
+
,,,,print(" ".join(board))
|
64
64
|
|
65
|
-
|
65
|
+
,,,,e = wrong + 1
|
66
66
|
|
67
|
-
|
67
|
+
,,,,print("\n".join(stages[0:e]))
|
68
68
|
|
69
|
-
|
69
|
+
,,,,if "_" not in board:
|
70
70
|
|
71
|
-
|
71
|
+
,,,,,,,,print("あなたの勝ち!")
|
72
72
|
|
73
|
-
|
73
|
+
,,,,,,,,print(" ".join(board))
|
74
74
|
|
75
|
-
|
75
|
+
,,,,,,,,win = True
|
76
76
|
|
77
|
-
|
77
|
+
,,,,,,,,break
|
78
78
|
|
79
|
-
|
79
|
+
,,,,if not win:
|
80
80
|
|
81
|
-
|
81
|
+
,,,,,,,,,,,,print("\n".joint(stages[0:wrong+1]))
|
82
82
|
|
83
|
-
|
83
|
+
,,,,,,,,,,,,print("あなたの負け!正解は{}.".format(word))
|
84
84
|
|
85
85
|
|
86
86
|
|