question 85 Functions · medium
Longest winning streak
A league page shows each team's longest run of consecutive wins. Results are stored in match order as "W", "D" or "L". Any draw or loss ends a run.
Function
longest_streak(results)resultsa list of
"W", "D" and "L", in match orderReturnsthe length of the longest run of
"W" in a row; 0 if there are no winsExamples
calllongest_streak(['W', 'W', 'L', 'W', 'W', 'W', 'D'])returns3
calllongest_streak(['L', 'D', 'L'])returns0
calllongest_streak(['W'])returns1