質問編集履歴
1
ソースコードにコメントを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
class Read_file:
|
55
|
+
class Read_file: #ファイルの読み込み
|
56
56
|
|
57
57
|
def __init__(self):
|
58
58
|
|
@@ -72,7 +72,7 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
-
class Undup_list:
|
75
|
+
class Undup_list:
|
76
76
|
|
77
77
|
def __init__(self, list):
|
78
78
|
|
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
-
def undup_list(self):
|
83
|
+
def undup_list(self): #名前の取り出し
|
84
84
|
|
85
85
|
new_list = []
|
86
86
|
|
@@ -94,7 +94,9 @@
|
|
94
94
|
|
95
95
|
|
96
96
|
|
97
|
-
def count_element(self, element):
|
97
|
+
def count_element(self, element): #elementの数をカウント
|
98
|
+
|
99
|
+
|
98
100
|
|
99
101
|
return self.list.count(element)
|
100
102
|
|
@@ -108,13 +110,13 @@
|
|
108
110
|
|
109
111
|
name_count =[]
|
110
112
|
|
111
|
-
file_in = Read_file()
|
113
|
+
file_in = Read_file() #インスタンス生成
|
112
114
|
|
113
115
|
name_in = file_in.read_file()
|
114
116
|
|
115
117
|
|
116
118
|
|
117
|
-
name = Undup_list(name_in)
|
119
|
+
name = Undup_list(name_in) #インスタンス生成
|
118
120
|
|
119
121
|
name_list = name.undup_list()
|
120
122
|
|
@@ -124,7 +126,7 @@
|
|
124
126
|
|
125
127
|
name_count.append(name.count_element(name_list[i]))
|
126
128
|
|
127
|
-
print(dict(zip(name_list, name_count))) #
|
129
|
+
print(dict(zip(name_list, name_count))) #辞書に変換
|
128
130
|
|
129
131
|
```
|
130
132
|
|