Next Monday

EasyDatetime Programs · 18 of 20

Write a Python program to find the date of the next Monday after a given date.

Advertisement
Output
2026-11-02 -> 2026-11-09
2026-11-05 -> 2026-11-09

Approach

  1. Days to add = (7 – weekday) % 7, or a full 7 days if the date is already a Monday.

Solution

Python
from datetime import date, timedelta def next_monday(d):    return d + timedelta(days=(7 - d.weekday()) % 7 or 7) for d in [date(2026, 11, 2), date(2026, 11, 5)]:    print(d, "->", next_monday(d))
Output
2026-11-02 -> 2026-11-09
2026-11-05 -> 2026-11-09

Line by line

Line 4

For a Monday the formula gives 0, so or 7 moves to the following Monday.

Learn the concept

New to this topic? Read the lesson, then come back.

More datetime programs

← All 20 Datetime Programs

Leave a Comment