def char_lookup(c: str, table: dict, default=None):
    """
    Translate a char into a value by looking up from a dict.

    Args:
        c: char to translate
        table: a dict to translate the char by looking up
        default: If not None, this is the value to return in case the char does not exist in the table.

    Returns:
        Translated value for the char by looking up the char into table.
    """
    if c in table:                  # Match word in case-sentitive mode is the first priority
        return table[c]
    else:
        if default is not None:
            return default
        else:
            raise KeyError('Key `{}` not found'.format(c))