Longest activity streak

Mediumfor loopmax· 20 XP

For each day, the app records 1 if the user was active and 0 if not. The streak badge needs the longest run of active days in a row.

Write a function longest_streak(days) that returns the length of the longest run of 1s in a row.

How it's checked

Your code runs, then the check below runs and its printed output is compared with ours.

  • longest_streak([1, 1, 0, 1, 1, 1, 0]) returns 3
  • A list with no 1s gives 0

Hints, the later steps and the answer come with Pro.

def longest_streak(days):
    ...