Get Number of Days in Month for Given Year using Python

calendar module

from calendar import monthrange

year = 2024
month = 2
numberOfDays = monthrange(year, month)[1]

print(numberOfDays)

Leave a Comment

Cancel reply

Your email address will not be published.