What is the output?
a, *b, c = [1, 2, 3, 4, 5] print(b)
- [2, 3, 4]
- [2, 3]
- (2, 3, 4)
- [1, 2, 3, 4]
The starred name collects everything the other targets do not take, always as a list: a gets 1, c gets 5, b gets [2, 3, 4].
Play Problem Solving ▸
a, *b, c = [1, 2, 3, 4, 5] print(b)