I want to create dictionary that key is ‘smoking stauts’ value is ‘charges’. But my code print out dictionary only last two pairs. how to figure out . pls help me
import csv
ages = []
sex = []
bmi = []
children = []
smoker = []
region = []
charges = []
with open('insurance.csv', newline = '') as insurance_csv:
reading_data = csv.DictReader(insurance_csv)
for row in reading_data:
ages.append(row['age'])
sex.append(row['sex'])
bmi.append(row['bmi'])
children.append(row['children'])
smoker.append(row['smoker'])
region.append(row['region'])
charges.append(row['charges'])
charge_dict = {smoker:charges for smoker,charges in zip(smoker, charges)}
{'yes': '29141.3603', 'no': '2007.945'}