I would like to ask if I can reduce many if statements in Python. I've had a problem with many if statements in my budget tracker program. The user for example get money every Month, he have expenses every Week and recurring expenses every Month. But he want to show for example savings for a day. That's many if statements to do every if. If he want to show savings for a day and other things are Month I need divide other things by days of the current Month, then I can count the savings for a day (savings = income - expenses - recurring expenses). I think you can understand me, if not ask me.Sorry if I writed something wrong here, my English isn't perfect.
phases = ['Day','Week','two weeks','three weeks','Month','three months','half a year','Year','two years','five years']
if self.combobox_value_savings == 'Day':
if self.combobox_value_phase_income == 'Day':
if self.combobox_value_phase_recurring == 'Day':
if self.combobox_value_phase_expenses == 'Day':
# everything the same -> nothing changes
elif self.combobox_value_phase_expenses == 'Week':
self.expenses /= 7
elif self.combobox_value_phase_expenses == 'two weeks':
self.expenses /= 14
elif self.combobox_value_phase_expenses == 'three weeks':
self.expenses /= 21
# ...
Thanks in advance!