回答編集履歴
2
改善 0 ~ 5 の KEY は不要でした。
test
CHANGED
@@ -59,3 +59,63 @@
|
|
59
59
|
# 以下共通の質問を行う
|
60
60
|
|
61
61
|
```
|
62
|
+
|
63
|
+
#改善コード
|
64
|
+
|
65
|
+
辞書の不要な KEY 0 ~ 5 を削除しリストに
|
66
|
+
|
67
|
+
```Python
|
68
|
+
|
69
|
+
import random
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
# 専用質問
|
74
|
+
|
75
|
+
sp_lst = [
|
76
|
+
|
77
|
+
('お題1', '質問1', '質問2', '質問3'),
|
78
|
+
|
79
|
+
('お題2', '質問4', '質問5', '質問6'),
|
80
|
+
|
81
|
+
('お題3', '質問7', '質問8', '質問9'),
|
82
|
+
|
83
|
+
('お題4','質問10','質問11','質問12'),
|
84
|
+
|
85
|
+
('お題5','質問13','質問14','質問15'),
|
86
|
+
|
87
|
+
('お題6','質問16','質問17','質問18')
|
88
|
+
|
89
|
+
]
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
def special_quest(lst):
|
94
|
+
|
95
|
+
"""
|
96
|
+
|
97
|
+
lst format: [('お題1', '質問1', '質問2', ...), (...), ...]
|
98
|
+
|
99
|
+
"""
|
100
|
+
|
101
|
+
ans = dict()
|
102
|
+
|
103
|
+
idx = random.randrange(len(lst)) # 0 ~ 5 のどれか: 5 は len(lst)-1
|
104
|
+
|
105
|
+
print(lst[idx][0])
|
106
|
+
|
107
|
+
for st in lst[idx][1:]:
|
108
|
+
|
109
|
+
ans[st] = input(st + " > ")
|
110
|
+
|
111
|
+
return ans
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
sp_ans = special_quest(sp_lst)
|
116
|
+
|
117
|
+
print(*sp_ans.items())
|
118
|
+
|
119
|
+
# 以下共通の質問を行う
|
120
|
+
|
121
|
+
```
|
1
defaultdict は不要のため修正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
import random
|
6
6
|
|
7
|
-
from collections import defaultdict
|
7
|
+
#from collections import defaultdict
|
8
8
|
|
9
9
|
|
10
10
|
|
@@ -36,7 +36,9 @@
|
|
36
36
|
|
37
37
|
"""
|
38
38
|
|
39
|
-
ans = defaultdict(list)
|
39
|
+
#ans = defaultdict(list)
|
40
|
+
|
41
|
+
ans = dict()
|
40
42
|
|
41
43
|
idx = random.randrange(len(dic)) # 0 ~ 5 のどれか: 5 は len(dic)-1
|
42
44
|
|