runtime
85 / 500
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.

Functionlongest_streak(results)
resultsa list of "W", "D" and "L", in match order
Returnsthe length of the longest run of "W" in a row; 0 if there are no wins
Examples
calllongest_streak(['W', 'W', 'L', 'W', 'W', 'W', 'D'])returns3
calllongest_streak(['L', 'D', 'L'])returns0
calllongest_streak(['W'])returns1

Loading your progress…

Longest winning streak — Python practice · Runtime