A Window on the Day

Python FundamentalsMedium+10 XP+10

A Window on the Day

A step counter stores how many steps you took in each hour, starting from hour 0.

Task: write steps_window(hourly_steps, start_hour, hours) that returns the readings for hours hours in a row, beginning at start_hour.

  • start_hour is a position in the list (the first reading is hour 0).
  • The window always fits inside the list. hours may be 0, which gives an empty list.

Examples

hourly_steps = [120, 400, 950, 300, 80, 610]
start_hour = 1
hours = 3
returns [400, 950, 300]
hourly_steps = [120, 400, 950, 300, 80, 610]
start_hour = 0
hours = 2
returns [120, 400]

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