Count How Many People Join In 1st Half And 2nd Half
import csv result = {} with open('1000 Records.csv', 'r') as csv_file: csv_reader = csv.reader(csv_file) for row in csv_reader: year_of_j
Solution 1:
You're close, but you need to set 0
somewhere, and accumulate some results
import csv
result = {}
with open('records.csv') as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
year_of_joining = int(row['Year of Join'])
half_of_joining = row['Half of Join']
if year_of_joining not in result:
result[year_of_joining] = {'H1': 0, 'H2': 0}
result[year_of_joining][half_of_joining] += 1
Post a Comment for "Count How Many People Join In 1st Half And 2nd Half"