runtime
172 / 500
question 172 Exceptions & Validation · easy

The delay that is always zero

The flights dashboard shows an average departure delay of 0 minutes for every airport, even on stormy days. average_delay should return the mean of the delays, and 0 only when there are no flights. Fix it, and make sure the next typo can't hide the same way.

Functionaverage_delay(delays)
delaysa list of departure delays in minutes (negative means early)
Returnsthe mean delay, or 0 for an empty list
Rulehandle only the error an empty list really causes
Examples
callaverage_delay([-4, 12, -1, 35])returns10.5
callaverage_delay([0, 30])returns15.0
callaverage_delay([])returns0

Loading your progress…

The delay that is always zero — Python practice · Runtime