• Lightbulb Start Watching 2

 

what is wrong?

from datetime import datetime from typing import List, Optional

def sumlight(els: List[datetime], startwatching: Optional[datetime] = None) -> int: t = 0; sw = startwatching for k in range(1, len(els)): if (sw - els[k]).totalseconds() <= 0: if k % 2 == 1: els[k - 1] = sw; break

for i in range(k,len(els),2):
    t = t + (els[i] - els[i - 1]).total_seconds()
return(int(t))

''' TypeError: unsupported operand type(s) for -: 'NoneType' and 'datetime.datetime', sumlight, 68 Fail: sumlight([ datetime(2015, 1, 12, 10, 0, 0), datetime(2015, 1, 12, 10, 10, 10), datetime(2015, 1, 12, 11, 0, 0), datetime(2015, 1, 12, 11, 10, 10) ]) '''

.
14