# itermonthdays2()

Calendar Module

 `month` Month number for which dates are requried `year` Year number for which dates are requried
itermonthdays2() : Returns an Iterator of tuples having days of the month and week day number.

Note that days will be returned as 0 per the days for the week starting from Previous month and for days for the week extended up to next month. This is our first or 0th element of the tuple.

Week day number starts from 0 as Monday , 1 as Tuesday and ends at 6 as Sunday. This is our second or 1th element of the tuple.
``````import calendar
my_cal= calendar.Calendar()
for x in my_cal.itermonthdays2(2020,7):
print(x)``````
Output
``````(0, 0)
(0, 1)
(1, 2)
(2, 3)
(3, 4)
(4, 5)
(5, 6)
(6, 0)
------
------
(27, 0)
(28, 1)
(29, 2)
(30, 3)
(31, 4)
(0, 5)
(0, 6)``````
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.itermonthdays2(2020,7):
print(x)``````
Output
``````(0, 3)
(0, 4)
(0, 5)
(0, 6)
(0, 0)
(0, 1)
(1, 2)
----
----
----
(30, 3)
(31, 4)
(0, 5)
(0, 6)
(0, 0)
(0, 1)
(0, 2)
``````
As we are getting tuple as output, we can get first element as day number and second element as day of the week.
``````import calendar
my_cal= calendar.Calendar(firstweekday=3)
for x in my_cal.itermonthdays2(2020,7):
print('day:',x,', weekday : ',x)``````
Output
``````day: 0 , weekday :  3
day: 0 , weekday :  4
day: 0 , weekday :  5
day: 0 , weekday :  6
day: 0 , weekday :  0
day: 0 , weekday :  1
day: 1 , weekday :  2
day: 2 , weekday :  3
---------------------
---------------------
day: 29 , weekday :  2
day: 30 , weekday :  3
day: 31 , weekday :  4
day: 0 , weekday :  5
day: 0 , weekday :  6
day: 0 , weekday :  0
day: 0 , weekday :  1
day: 0 , weekday :  2`````` plus2net.com