from typing import List
import re


def parse_seasons(seasons: List[str]):
    """Parses a string of seasons into a list of seasons. Used by main and by collect_course_length main"""
    parsed_seasons = []
    for season in seasons:
        if re.match("[0-9]{4}\-[0-9]{4}", season):
            int_range = list(map(int, season.split("-")))
            # increase end so our range is inclusive
            int_range[1] += 1
            parsed_seasons += list(map(str, range(*int_range)))
        elif re.match("[0-9]{4}", season):
            parsed_seasons.append(season)
        else:
            raise ValueError("The season must be a valid 4-digit year")
    return parsed_seasons