Python Practice › Datetime Programs › Program 8
Is a date a weekend?
Write a Python program to check whether dates fall on a weekend.
Output
2026-10-31 weekend 2026-11-02 weekday
Approach
weekday()is 5 or 6 for Saturday and Sunday.
Solution
from datetime import date for d in [date(2026, 10, 31), date(2026, 11, 2)]: print(d, "weekend" if d.weekday() >= 5 else "weekday")Output
2026-10-31 weekend 2026-11-02 weekday
Learn the concept
New to this topic? Read the lesson, then come back.