I need to calculate the number of days for a given month in python. If a user inputs Feb 2011 the program should be able to tell me that Feb 2011 has 28 days. Could anyone tell me which library I should use to determine the length of a given month?
Share
You should use
calendar.monthrange:Just to be clear,
monthrangesupports leap years as well:As @mikhail-pyrev mentions in a comment: