Python calendar module | iterweekdays() method
Calendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions.
iterweekdays() method returns an iterator for the week day numbers that will be used for one week. The first number from the iterator will be the same as the number returned by firstweekday().
Syntax: iterweekdays() Parameter: no parameter Returns: iterator for the week day numbers
Code #1:
# Python program to demonstrate working # of iterweekdays() method # importing calendar module import calendar # providing firstweekday = 0 obj = calendar.Calendar(firstweekday = 0) for day in obj.iterweekdays(): print(day) |
Output:
0 1 2 3 4 5 6
Code #2:
# Python program to demonstrate working # of iterweekdays() method # importing calendar module import calendar # providing firstweekday = 2 obj = calendar.Calendar(firstweekday = 2) for day in obj.iterweekdays(): print(day) |
Output:
2 3 4 5 6 0 1
Recommended Posts:
- Python calendar module | pryear() method
- Python calendar module | prmonth() method
- Python calendar module | isleap() method
- Python calendar module | monthdays2calendar() method
- Python calendar module | monthdayscalendar() method
- Python calendar module | itermonthdays2() method
- Python calendar module | itermonthdays() method
- Python calendar module | yeardayscalendar() method
- Python calendar module | monthdatescalendar() method
- Python calendar module | formatmonth() method
- Python calendar module | yeardatescalendar() method
- Python calendar module | setfirstweekday() method
- Python calendar module | yeardays2calendar() method
- Python calendar module | formatyear() method
- Python calendar module | itermonthdates() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



