month | Month number for which dates are required |
year | Year number for which dates are required |
import calendar
my_cal= calendar.Calendar()
for x in my_cal.itermonthdays(2020,7):
print(x)
Output
0
0
1
2
3
4
5
--
--
28
29
30
31
0
0
By updating the first day of the week we can get different elements of the iterator.
import calendar
my_cal= calendar.Calendar(firstweekday=3)
for x in my_cal.itermonthdays(2020,7):
print(x)
Output
0
0
0
0
0
0
1
2
3
4
--
--
--
27
28
29
30
31
0
0
0
0
0
Calendar Module in Python itermonthdays2() tuple with week days
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.