Multiple Unpacking Assignment in Python when you don’t know the sequence length

Python 3.x can do this easily:

a, b, *c = someseq

Python 2.x needs a bit more work:

(a, b), c = someseq[:2], someseq[2:]

Leave a Comment