PythiloEasy · 12 min · Task 45 of 100 · progress kept in this browser

Longest run of ones

Return the length of the longest consecutive run of 1 values in a binary list. Empty input returns zero.

current = 2
for value in [1, 0]:
    current = current+1 if value == 1 else 0
    print(current)
Your task

Return the length of the longest consecutive run of 1 values in a binary list. Empty input returns zero.