r/PythonLearning • • 3d ago

Python Quiz of the Day.

What will be the output of the following Python Code?

a, *b, c = [2, 4, 6, 8, 10]

print(a + c + len(b))

6 Upvotes

2 comments sorted by

View all comments

3

u/RNG_HatesMe 2d ago

so *b grabs everything BUT the first and last elements, which get assigned to a and c.

so b gets [4,6,8] and has length 3.

so a + c + len(b) = 2 + 10 + 3 = 15