Dates and times · 14 / 15 Exercise Hard

Working days

Objective

Create a Python program that counts the working days (Monday to Friday) between two dates, both included, going through the days one by one with timedelta(days=1).

Instructions

  • Read an integer n and then n lines with two dates YYYY-MM-DD separated by a space (the second is equal to or later than the first).
  • Start at the first date and move forward one day at a time while you do not go past the second. Count the days whose weekday() is less than 5 (Monday to Friday). There are no holidays.
  • Show Working days: d for each line.
Input
2
2026-11-09 2026-11-13
2026-11-09 2026-11-22
Output
Working days: 5
Working days: 10

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise