Solve 7.8 LAB
This commit is contained in:
1
7/7.8 LAB/input1.csv
Normal file
1
7/7.8 LAB/input1.csv
Normal file
@@ -0,0 +1 @@
|
|||||||
|
hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy
|
||||||
|
18
7/7.8 LAB/main.py
Normal file
18
7/7.8 LAB/main.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import csv
|
||||||
|
|
||||||
|
with open(input(), newline='') as f:
|
||||||
|
reader = csv.reader(f)
|
||||||
|
data = list(reader)[0]
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
|
||||||
|
for entry in data:
|
||||||
|
try:
|
||||||
|
result[entry]
|
||||||
|
|
||||||
|
result[entry] = result[entry] + 1
|
||||||
|
except KeyError:
|
||||||
|
result[entry] = 1
|
||||||
|
|
||||||
|
for key in result:
|
||||||
|
print('{0} {1}'.format(key, result[key]))
|
||||||
Reference in New Issue
Block a user