Python Calendar Module : monthdayscalendar() method
monthdayscalendar() method
The monthdayscalendar() method is used to get a list of the weeks in the month of the year as full weeks. Weeks are lists of seven-day numbers.
Syntax:
monthdayscalendar(year, month)
Parameters:
Name | Description | Required / Optional |
Type |
---|---|---|---|
year | Year for which the calendar should be generated. | Required | Number |
month | Month for which the calendar should be generated. | Required | Number |
Example of monthdayscalendar() method
import calendar
cal= calendar.Calendar()
print(cal.monthdayscalendar(2016, 5))
Output:
[[0, 0, 0, 0, 0, 0, 1], [2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28, 29], [30, 31, 0, 0, 0, 0, 0]]
Previous: monthdays2calendar()
Next: yeardatescalendar()
Test your Python skills with w3resource's quiz
Python: Tips of the Day
What is the difference between Python's list methods append and extend?
append: Appends object at the end.
x = [1, 2, 3] x.append([4, 5]) print (x)
Output:
[1, 2, 3, [4, 5]]
extend: Extends list by appending elements from the iterable.
x = [1, 2, 3] x.extend([4, 5]) print (x)
Output:
[1, 2, 3, 4, 5]
Ref: https://bit.ly/2AZ6ZFq
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework