Question 13
Back to Exercise
What is the output of the following Python program?
first, *mid, last = [1, 2, 3, 4, 5]
print(first, mid, last)
a, *b = [9]
print(a, b)
- A 1 (2, 3, 4) 5 9 ()
- B 1 [2, 3, 4] 5 ValueError
- C 1 [2, 3, 4] 5 9 [] Correct
- D 1 2 5 9 None
Correct Answer: Option C
The starred name always gets a list – possibly empty.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!