Python ProgrammingPython Programming

Find the previous and coming Monday's date, based on current date

# Python's program to get last and coming Monday

import datetime

today =
last_monday = today - datetime.timedelta(days=today.weekday())
coming_monday = today + datetime.timedelta(days=-today.weekday(), weeks=1)
print("Today:", today)
print("Last Monday:", last_monday)
print("Coming Monday:", coming_monday)

Sample output of above program.
C:\programs\time>pep8 --first

Today: 2018-01-21
Last Monday: 2018-01-15
Coming Monday: 2018-01-22