A handy Python trick called extended iterable unpacking lets you extract the first, last, and middle elements of a list in a single line—no indexing required.
Simply use the star operator (*) to capture the middle items:
first, *middle, last = [10, 20, 30, 40]
After this assignment:
firstbecomes10middlebecomes[20, 30]lastbecomes40
This technique, introduced in Python 3, helps write cleaner, more readable code. It’s especially useful for beginners learning Python programming. For more Python tips, follow the CodersAura channel.