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

Updated on: 30-Jul-2019

290 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements