get the date 5 weeks from now in python

You can get the date 5 weeks from now by using the timedelta function from the datetime module in Python. Here's the code:

main.py
from datetime import date, timedelta

today = date.today()  # get today's date
five_weeks = timedelta(weeks=5)  # create a timedelta object for 5 weeks
five_weeks_from_now = today + five_weeks  # add the timedelta to today's date

print(five_weeks_from_now)
258 chars
8 lines

This code will print the date 5 weeks from now in the format YYYY-MM-DD.

gistlibby LogSnag