Python Lists: Medical Insurance Project

https://www.codecademy.com/paths/data-science/tracks/dscp-python-fundamentals/modules/dscp-python-lists/projects/ds-python-lists1-project

Hi, I came back to this exercise after completing the loops module. i’m wondering if this can be solved by nested loops i’m sure it can but i’m unable to get the right solution using nested loops.

someone please go through my code and point out the mistakes and may be proper solution using nested loops. Appreciated

image

Found the answer guys, after browsing through the python looping techniques documentation… its really simple than i imagined…
Here’s the solution, just zip the both lists in for loop and then calculated the difference.

image

Here’s a way to do it without using a function, if you’re so inclined

image

Here’s another way if it helps.

for i in range(len(estimated_insurance_data)):
    insurance_cost_difference.append(estimated_insurance_data[i][-1] - insurance_data[i][-1])