Python Loops: Medical Insurance Estimates vs. Costs Project

Hi I am stuck on the project
Python Loops: Medical Insurance Estimates vs. Costs Project
Use a for loop to iterate through actual_insurance_costs and add each insurance cost to the variable total_cost .

i looke at hint total_cost += insurance_cost, I dont understand this += why use it here?

That is one of the group of assignment operators which augments the current value to build up a tally (total).

a = 6
a += 7
print (a)    #  13


my code is keep giving File “”, line 7
total_cost += isurance_cost
IndentationError: expected an indented block

1 Like

Since that line is in a loop body, it needs to be indented.


One gets the feeling you may have opted to challenge yourself by jumping right into a project, before completing the Learn Python 3 track. You’ll find that course is most essential to get ourselves up to speed. Suggest pause this project and look for that course in your dashboard. Spend the holidays working on it and you’ll find the projects a little easier to think through. They are intentionally written to let us see how much we are picking up and understanding.

Sorry only replied to you now, I am following the course data science step by step , but really find it difficult to understand the questions

Suggest take a deep dive into the Learn Python 3 track to reinforce the core of the language.

Can anyone explain why I’m getting this error? Looks to me like my code is the exact same as in the Hint provided.


Double check the print() above your for loop.

1 Like

Thanks! I see I left the closed parenthesis off… but why would it indicate the error is on line 12?

1 Like

Sometimes error messages are very specific and sometimes they refer to lines of code above.