Preview:
def count_first_mounth_days(
        start_year: int,
        start_month: int,
        stop_year: int,
        stop_month: int,
        week_day_index: int):
    """
        docstring
    """
    week = {
        1: "Monday",
        2: "Tuesday",
        3: "Wednesday",
        4: "Thursday",
        5: "Friday",
        6: "Saturday",
        7: "Sunday",
    }

    count = 0

    start_index = date(start_year, start_month, 1).isoweekday()
    stop_index = date(stop_year, stop_month, 1).isoweekday()
    print(start_index, week.get(start_index), date(start_year, start_month, 1).weekday())
    print(stop_index, week.get(stop_index), date(stop_year, stop_month, 1).weekday())

    for year in range(start_year, stop_year + 1):
        for month in range(
            start_month if year == start_year else 1,
            stop_month + 1 if stop_year == year else 13
        ):
            first_day = date(year, month, 1)
            if first_day.isoweekday() == week_day_index:
                # print(first_day, week.get(first_day.isoweekday()))
                count += 1
    return count
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter