Longest Goal Streak

Python FundamentalsHard+10 XP+10

Longest Goal Streak

A step-counter app tracks your steps each day. A day meets the goal if its steps are greater than or equal to goal.

Task: write longest_streak(daily_steps, goal) that returns the length of the longest run of days in a row that all meet the goal.

  • If no day meets the goal (or the list is empty), return 0.

Here the runs that meet the goal are 12000, 11000 (2 days) and 10500, 10000, 13000 (3 days). The longest is 3.

Examples

daily_steps = [8000, 12000, 11000, 4000, 10500, 10000, 13000]
goal = 10000
returns 3
daily_steps = [5, 6, 7]
goal = 6
returns 2

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run