Skip to main content
Python Output Prediction Medium +20 XP

Unpacking Values

What gets printed?

PythonRead-only
a, *b, c = [1, 2, 3, 4, 5]
print(b)

What is the output?

Show answer and explanation

Answer: [2, 3, 4]

*b captures all middle elements. a=1, b=[2,3,4], c=5.

Hint: * captures remaining elements.

What this challenge tests

Output Prediction in Python: unpacking, lists.

Related challenges