Shift Schedule Rotation Printer

Medium ⏱ 12 min 55% acceptance ★★★★★ 4.8
Write a function shift_schedule(employees, num_days) that assigns employees to shifts in a rotating round-robin over num_days days: day i (0-indexed) is worked by employees[i % len(employees)]. Return a list of num_days strings formatted "Day X: name" (X is 1-indexed).

Examples

Example 1
Input
shift_schedule(["Ana", "Ben"], 4)
Output
["Day 1: Ana", "Day 2: Ben", "Day 3: Ana", "Day 4: Ben"]
Explanation

Rotates through the two employees cyclically.

Constraints

  • employees is a non-empty list of names.
  • num_days is a positive integer.

Topics

Loopsfor loopBusiness Logic

Companies

SwiggyZomatoUber

Hints

Hint 1

Use `employees[i % len(employees)]` inside a loop over `range(num_days)` to wrap around.

Hint 2

The day label should be `i + 1` for 1-indexed display.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.