You cannot unpack a tuple by replacing such values โโ(for now - see PEP 448 ), since unpacking will occur only on the left side or, as indicated in the error message, the destination is assigned.
In addition, the target must have valid Python variables. In your case, you have string literals also in the tuple.
But you can build the tuple you need by combining three tuples, for example
>>> l = [1, 2, 3, 4] >>> ("A", "B") + tuple(l[:-1]) + ("C",) ('A', 'B', 1, 2, 3, 'C') >>> ("A", "B") + tuple(l) + ("C",) ('A', 'B', 1, 2, 3, 4, 'C')
thefourtheye
source share