Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Combining lists with two lists of costs?

Hello I need help with combining lists where I am given two lists of costs from 2017 and 2018, to combine them into a single list called combined_costs and then calculate the sum of the costs from 2017-2018 called total_costs.

costs_2017 = [1300, 1500, 1360, 1789, 611]

costs_2018 = [1545, 789, 913, 8854, 462]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I figured out how to do the combined_costs:

combined_costs = cost_2017 + cost_2018

len(combined_costs)

But as for total_costs, I’m not sure if I am heading in the right direction but this is all I have for total_costs:

total_costs = combined_costs

>Solution :

If you are looking for a sum then:

total_costs = sum(combined_costs)

which is:

19123
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading