def num_leading_spaces(text: str, space_char: str = " ") -> int:
    """Count number of leading spaces in a string

    Args:
        text:        String to count.
        space_char:  Which characters count as spaces.

    Returns:
        Number of leading spaces.
    """
    return len(text) - len(text.lstrip(space_char))