base.py
def basedigit(c: str, base: int) -> int:
    """Interpret a character as a single-digit integer in the given
    base."""
    if len(c) != 1:
        raise TypeError(
            f'basedigit() expected a character, but string of length {len(c)}'
            'found'
        )

    if base <= 10:
        digit = ord(c) - ord('0')

        if 0 <= digit < 10:
            return digit

        raise ValueError(
            f'invalid character for basedigit() with base {base}: {repr(c)}'
        )
    elif base <= 36:
        digit = ord(c) - ord('0')

        if 0 <= digit < 10:
            return digit
        
        digit = ord(c) - ord('a')

        if 0 <= digit < base:
            return 10 + digit

        raise ValueError(
            f'invalid character for basedigit() with base {base}: {repr(c)}'
        )

    raise ValueError(f'invalid base for basedigit(): {base}')
Interpret a character as a single-digit integer in the given
    base.
Interpret a character as a single-digit integer in the given
base.
Interpret a character as a single - digit integer in the given base .
def basedigit(c: str, base: int) -> int:
    if len(c) != 1:
        raise TypeError(
            f'basedigit() expected a character, but string of length {len(c)}'
            'found'
        )
    if base <= 10:
        digit = ord(c) - ord('0')
        if 0 <= digit < 10:
            return digit
        raise ValueError(
            f'invalid character for basedigit() with base {base}: {repr(c)}'
        )
    elif base <= 36:
        digit = ord(c) - ord('0')
        if 0 <= digit < 10:
            return digit
        digit = ord(c) - ord('a')
        if 0 <= digit < base:
            return 10 + digit
        raise ValueError(
            f'invalid character for basedigit() with base {base}: {repr(c)}'
        )
    raise ValueError(f'invalid base for basedigit(): {base}')
def basedigit ( c : str , base : int ) -> int : if len ( c ) != 1 : raise TypeError ( f'basedigit() expected a character, but string of length {len(c)}' 'found' ) if base <= 10 : digit = ord ( c ) - ord ( '0' ) if 0 <= digit < 10 : return digit raise ValueError ( f'invalid character for basedigit() with base {base}: {repr(c)}' ) elif base <= 36 : digit = ord ( c ) - ord ( '0' ) if 0 <= digit < 10 : return digit digit = ord ( c ) - ord ( 'a' ) if 0 <= digit < base : return 10 + digit raise ValueError ( f'invalid character for basedigit() with base {base}: {repr(c)}' ) raise ValueError ( f'invalid base for basedigit(): {base}' )
Interpret a character as a single-digit integer in the given
base.
Interpret a character as a single - digit integer in the given base .
"""Interpret a character as a single-digit integer in the given
    base."""
c
str
base
int