 # US_Medical_Insurance_Project

Hi everybody,
I leave my solution for this project in the next link:

I hope it is useful for someone else and I await your comments for possible errors or suggestions.
Have a good day!
Gustavo

Nice analysis and documentation! The solution looks correct to me - here are just some suggestions to make the code a bit shorter:

1. To create a list with N zeros, you used:
``````[i * 0 for i in range(N)]
``````

Alternatively, you could use:

``````[0 for i in range(N)]
``````

or, even shorter:

``````*N
``````
1. In counting the patients according to region, you apply an if-elif-else statement of the form:
``````if charge == data:
cost = ...
elif charge == data:
cost = ...
else:
...
``````

Alternatively you could use the .index method of lists to find the index of charge in data and avoid the if-else completely:

``````idx = data.index(charge)
cost[idx] = ...
``````
1. The cost by age could also be accomplished with list comprehensions (e.g. for the cost of age 0-25):
``````cost_under_25 = [c for c in cost_by_age if c < 25]
average_cost_under_25 = sum(cost_under_25) / len(cost_under_25)
``````

Of course, using numpy and pandas would shorten the code even futrher Have a nice day!
Beta

Thank you so much for your comments. I’m sure that I will use these shorter ways in the future!