The question is a bit misleading, because a tuple is immutable. What I want is:
Having a tuple a = (1, 2, 3, 4) get a tuple b that is exactly like a except for the last argument which is, say, twice the last element of a.
=> b == (1, 2, 3, 8)
What I’m doing here is concatenation of two tuples, the first containing everything but the last element, and a new tuple containing the mutation of the final element. The result is a new tuple containing what you want.
Note that for
+to return a tuple, both operands must be a tuple.