You can unpack items from a list in Python by assigning them to multiple variables in a single line. Unpacking is one of the most coder-friendly features in Python, and it works flawlessly when the number of variables aligns with the number of elements in the list.
Basic List Unpacking
If you know exactly how many items the list contains:

Each list item is assigned to a corresponding variable.
Unpacking With the “Star” Operator (*)
Sometimes you want to capture multiple items at once.
Python’s extended iterable unpacking lets you use a * variable.
Example: Capturing the “rest

Example: Collecting everything but the first

Or everything but the last

Unpacking in Loops
This works great when iterating through lists of pairs or tuples:

Unpacking While Ignoring Values
You can use _ as a placeholder for unwanted items:

Quick Summary
When we talk about unpacking, we mean the process of taking elements from a packed data structure, like a list or tuple, and assigning them to separate variables.
Unpacking works in loops, function arguments, and more.