def i_replaced(list_, i, value):
    """ Returns a new list with element i replaced by value.
        Pass None to value to return list with element i removed.
    """
    if value is not None:
        return list_[:i] + [value] + list_[i + 1:]
    else:
        return list_[:i] + list_[i + 1:]
