Python: A program to find the LENGTH of the longest run in a given list?
You can do this in one line using itertools.groupby
:
import itertools
max(sum(1 for _ in l) for n, l in itertools.groupby(lst))
You can do this in one line using itertools.groupby
:
import itertools
max(sum(1 for _ in l) for n, l in itertools.groupby(lst))