def count_ending_spaces(line) -> int:
    """Counts the ending spaces of a line (string)"""

    spaces = 0
    for i in reversed(line):
        if i == " ":
            spaces += 1
        else:
            break

    return spaces