Skip to content
Advertisement

Python (Sum of expense, income, and profit)

In Python I have a list of entries. I need to get the sum of expenses, the sum of income, and the profit. I’ve been able to get the expenses and income. Looking to break out the profit. I know I’m missing something simple but can’t figure it out.

JavaScript

Advertisement

Answer

Looks like you just want to calculate the profit/expenses/income for the entire list, so you shouldn’t set “profit = 0” after every iteration, instead just set it in the beginning.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement