import csv
age =
sex =
bmi =
children =
smoker =
region =
charges =
total_age = 0
southwest_c = 0
southest_c = 0
northwest_c = 0
northest_c = 0
count = 0
with open(“insurance.csv”, ‘r’) as insurance:
csv = csv.DictReader(insurance)
for row1 in csv:
count += 1
region.append(row1[“region”])
print(count)
southest_c=region.count(“southeast”)
southwest_c=region.count(“southwest”)
northest_c=region.count(“northeast”)
northwest_c=region.count(“northwest”)
total_pop = len(region)
print(southest_c)
print(total_pop)
print("There are " + str(southest_c) + " pepole in Southeast region. That means " + str(
float(southest_c / total_pop) * 100) + “%.”)
print("There are " + str(southwest_c) + " pepole in Southwest region. That means " + str(
float(southwest_c / total_pop) * 100) + “%.”)
print("There are " + str(northest_c) + " pepole in Northeast region. That means " + str(
float(northest_c / total_pop) * 100) + “%.”)
print("There are " + str(northwest_c) + " pepole in Northwest region. That means " + str(
float(northwest_c / total_pop) * 100) + “%.”)
for row in csv:
** age.append(row[“age”])**
** for i in age:**
** total_age = total_age + float(i)**
** print(total_age)**
** average_age = total_age / len(age)**
** print(average_age)**
The part with BOLD is not working, and i can t recall why. Some help please?