Answer the question
In order to leave comments, you need to log in
How to write a function for counting money spent for the last 7 days (starting with conditionally today)?
I'm preparing a money count calculator, I wrote a function "for today" (attached), but I just can't figure out how to beat the money count for the last 7 days. Need help.
def get_today_stats(self):
count = 0
sum_day = len(self.records)
for i in range(0, sum_day):
if self.records[i].date == dt.date:
count = self.records[i].amount + count
return count
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question