# Python Loops: Medical Insurance Estimates vs. Costs Project

Click “Save” to see the result.

## You should see the insurance costs for each of the seven individuals in names. The for loop iterated through the entire list and printed out the insurance cost for each individual.

Question: When inputting the code below, I am not sure why my output for Task 7 has brackets around the insurance cost. I don’t believe there should not be any. Can anyone explain why and how I can get rid of them? Please and thank you.

Output:
30800.0
Average Insurance Cost: [4400.0] dollars.
The insurance cost for Judith is [1100.0] dollars.
The insurance cost for Abel is [2200.0] dollars.
The insurance cost for Tyson is [3300.0] dollars.
The insurance cost for Martha is [4400.0] dollars.
The insurance cost for Beverley is [5500.0] dollars.
The insurance cost for David is [6600.0] dollars.
The insurance cost for Anabel is [7700.0] dollars.

#My code:
names = [“Judith”, “Abel”, “Tyson”, “Martha”, “Beverley”, “David”, “Anabel”]
estimated_insurance_costs = [1000.0, 2000.0, 3000.0, 4000.0, 5000.0, 6000.0, 7000.0]
actual_insurance_costs = [1100.0, 2200.0, 3300.0, 4400.0, 5500.0, 6600.0, 7700.0]

total_cost = 0

for element in actual_insurance_costs:
total_cost += element
print(total_cost)

average_cost = [total_cost / len(actual_insurance_costs)]
print(“Average Insurance Cost: " + str(average_cost) + " dollars.”)

## for i in range(len(names)): name = names[i] insurance_cost = [actual_insurance_costs[i]] print(“The insurance cost for " + name + " is " + str(insurance_cost) + " dollars.”)

1 Like

Try removing square brackets from the code `insurance_cost = [actual_insurance_costs[i]]` so the code will look like this `insurance_cost = actual_insurance_costs[i]`

Hope it works.

You also don’t need brackets here:

try:

``````average_cost = total_cost/len(actual_insurance_costs)
``````

@josefroslan and @lisalisaj Thank you so much! Both average_cost and insurance_cost needed the brackets to go away.

When only removing the insurance_cost brackets, I get this error:
Traceback (most recent call last):
File “script.py”, line 20, in
if insurance_cost > average_cost:
TypeError: ‘>’ not supported between instances of ‘float’ and ‘list’

Anyways, appreciate you both answering so quickly!