3 ms·
BTW you can get head and tail with plain old unpacking :) >>> head, *tail = range(3) >>> head 0 >>> tail [1, 2] Granted, unpacking also co
by lou1306 5y ago
BTW you can get head and tail with plain old unpacking :)
>>> head, *tail = range(3)
>>> head
0
>>> tail
[1, 2]
Granted, unpacking also coalesces lazy iterables (like range in this case) into lists, but if you aren't working with large/infinite iterables you should be alright.