Open this example in the interactive library
Source code
first, *middle, last = [1, 2, 3, 4]
print(first, middle, last)Sample output
1 [2, 3] 4

Unpack with a remainder. A self-contained example using the Python standard library.
Open this example in the interactive library
first, *middle, last = [1, 2, 3, 4]
print(first, middle, last)1 [2, 3] 4