What is iterweekdays() in python?



iterweekdays() method. The iterweekdays() method returns an iterator for the weekday numbers that will be used for one week.

Example

#Write a python program to print iterweekdays() using list
import calendar
# prints firstweekday starts with 4 th day
day= calendar.Calendar(firstweekday = 4)
list(day.iterweekdays())

Output

[4, 5, 6, 0, 1, 2, 3]

Or

import calendar
#prints firstweekday starts with 0 th day
variable= calendar.Calendar(firstweekday = 0)
for day in variable.iterweekdays():
print(day)

Output

0
1
2
3
4
5
6
raja
Published on 24-May-2019 10:33:14
Advertisements