[Solved] Python amount of days in a month with a given year and month? [closed]


You can do all sorts of things with the calendar module:

import calendar

year = int(raw_input('Enter year: '))
month = int(raw_input('Enter month number: '))

print(calendar.monthrange(year, month)[1])

This considers leap years just fine, too.

Example:

Enter year: 2012
Enter month number: 2
29

solved Python amount of days in a month with a given year and month? [closed]