def safe_index(list: list, index: int):
    """
    Returns the list element at index.
    If the index is invalid, returns None instead.
    """
    try:
        return list[index]
    except IndexError:
        return None