Answer:
from datetime import datetime, date, timedelta
def count_weekdays(start_date, add_days, stop_year, weekday):
my_date = start_date
m = 0
while my_date.year != stop_year:
my_date = my_date + timedelta(days = add_days)
if my_date.isoweekday() == weekday:
m += 1
return m
date_val = date(1757,1,1)
try:
date_val = datetime.fromisoformat(input("Enter date in the format yyyy-mm-dd: "))
except ValueError:
print("Wrong isoformat string")
print(count_weekdays(date_val, 8, 1800, 1))
Explanation:
The datetime package of the python programming language has several time modules like the date, datetime, pytz, timedelta, etc, used to manipulate date and time in documents. The function count_weekdays has four parameters and returns the number of a specified weekday in a period of time.