Add Business Days to a Date

Hard ⏱ 18 min 35% acceptance ★★★★★ 4.5
Write add_business_days(start, n) returning the date n business days after start, skipping Saturdays and Sundays (date.weekday() gives 5 and 6 for them). Holidays are out of scope. Count only landed weekdays.

Examples

Example 1
Input
add_business_days(date(2026, 7, 24), 2)  # a Friday
Output
date(2026, 7, 28)  # Tuesday
Explanation

Monday is day 1, Tuesday day 2 — the weekend is skipped.

Constraints

  • Weekends never count.
  • n >= 1.

Topics

Date & Timetimedeltaweekday

Companies

Goldman SachsJPMorgan ChaseRazorpay

Hints

Hint 1

Loop: add one day, count it only if weekday() < 5.

Hint 2

timedelta(days=1) is the step.

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