Solve 7.8 LAB

This commit is contained in:
Joe S 2021-02-26 00:14:07 -05:00
parent 030dd0b611
commit 8e662c58bf
2 changed files with 19 additions and 0 deletions

1
7/7.8 LAB/input1.csv Normal file
View File

@ -0,0 +1 @@
hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy
1 hello cat man hey dog boy Hello man cat woman dog Cat hey boy

18
7/7.8 LAB/main.py Normal file
View 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]))