def METHOD_NAME(li: List, idx: int, default: Any = None) -> Any:
    """Get an element from a list without raising IndexError.
    Attempt to get the element with index idx from a list-like object li, and if the index is invalid (such as out of
    range), return default (whose default value is None).
    :return: an element of any type
    """
    if isinstance(li, list):
        try:
            return li[idx]
        except IndexError:
            return default
    return None