Task # 7:
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]
Add your code here
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.”)