def hex_digit(coord, digit=1):
    """
    Returns either the first or second digit of the hexadecimal representation of the given coordinate.
    :param coord: hexadecimal coordinate, int
    :param digit: 1 or 2, meaning either the first or second digit of the hexadecimal
    :return: int, either the first or second digit
    """
    if digit not in [1,2]:
        raise ValueError('hex_digit can only get the first or second digit of a hex number, was passed digit={}'.format(
            digit
        ))
    return int(hex(coord)[1+digit], 16)
Returns either the first or second digit of the hexadecimal representation of the given coordinate.
    :param coord: hexadecimal coordinate, int
    :param digit: 1 or 2, meaning either the first or second digit of the hexadecimal
    :return: int, either the first or second digit