def replace_at_index1(tup, ix, val):
    lst = list(tup)
lst[ix] = val
return tuple(lst)

def replace_at_index2(tup, ix, val):
    return tup[:ix] + (val,) + tup[ix + 1:]
Python: changing value in a tuple