Python ProgrammingPython Programming

Get the last Thursday of the current month using python

import calendar
from datetime import datetime

month = calendar.monthcalendar(datetime.today().year, datetime.today().month)

thrusday = max(month[-1][calendar.THURSDAY], month[-2][calendar.THURSDAY])
print(thrusday)
Output
27