Symptom
The calculate_monthly_total() function is supposed to return the total spending for a specific month. But it returns the total of all expenses regardless of month. The existing test passes because it expects the wrong value.
expenses = [
Expense(50.0, "food", "Jan lunch", date(2024, 1, 15)),
Expense(30.0, "food", "Jan dinner", date(2024, 1, 20)),
Expense(20.0, "food", "Feb lunch", date(2024, 2, 5)),
]
result = calculate_monthly_total(expenses, month=1, year=2024)
# Returns 100.0 (all expenses) instead of 80.0 (January only)
What you know
The function accepts month and year parameters but seems to ignore them. Both the function implementation and its test are wrong -- they agree with each other but produce incorrect behavior.
Hints
Python
Python ready
Test Output
▶
Click "Run Tests" to execute your code