In some companies, they pay their employees on the first day of every month.
If you want to know what day of the week will that be, you can
find that quickly in Python using the
calendar module.
Let us assume that you want to check the first day of the next month:
import calendar
first_day, _ = calendar.monthrange(2022, 12)
Now we can simply check the
day_name for that
first_day value that we got
from monthrange():
import calendar
# Get current month
first_day, _ = calendar.monthrange(2023, 1)
print(first_day)
print(calendar.day_name[first_day]) # Thursday
That’s basically it.