def filter_by_term(course: tuple[str, str, set], term: str) -> tuple[str, str, set]:
    """Return a copy of the given course with only sections that meet in the given term.

    The returned tuple has the same course code and title as the given course, and its
    sections set is a subset of the original.

    Note that a 'Y' section meets in BOTH 'F' and 'S' terms, and so should always be
    included in the returned course tuple.

    Preconditions:
      - term in {'F', 'S'}
    """
    return course[0], course[1], {s for s in course[2] if s[1] == 'Y' or s[1] == term}