Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second - call total_seconds() just once solution in Clear category for Lightbulb Intro by jakubbortlik
from datetime import datetime, timedelta
from typing import List
def sum_light(els: List[datetime]) -> int:
"""how long the light bulb has been turned on"""
els = iter(els)
return sum(((next(els) - start) for start in els), start=timedelta()).total_seconds()
Dec. 16, 2022