YouTip LogoYouTip

Python3 Month Days

# Python3.x Python Calculate Days in Each Month [![Image 3: Document Object Reference](#) Python3 Examples](#) The following code calculates the number of days in each month by importing the calendar module: ## Example (Python 3.0+) #!/usr/bin/python3# author by : www..com import calendar monthRange = calendar.monthrange(2016,9)print(monthRange) Executing the above code outputs: (3, 30) The output is a tuple. The first element is the day of the week for the first day of the queried month (0-6), and the second element is the number of days in that month. The output of the above example means that the first day of September 2016 is a Thursday, and the month has a total of 30 days. [![Image 4: Document Object Reference](#) Python3 Examples](#)
← Go ConstantsGo Data Types β†’