2 September 2026
Library Fines
Work out the fine for each book that was returned late.
A library allows readers a short grace period before charging late fines on book returns. You are given the number of days late for each returned book, the number of days grace, and the cost of the fine for each day beyond the grace period. For each book, calculate its fine: - A book returned within the grace period has no fine. - Otherwise, total up the daily fines only for the days after the grace period. Return the fines in the same order as the books. Return an empty list when there are no books.
Constraints
days_late contains at most 100 non-negative whole numbersfree_days and daily_fine are non-negative whole numbersEach fine is calculated separately for one book
Function signature
def library_fines(days_late, free_days, daily_fine):