assigning two variables to one list slice
list, pattern-matching, python, slice
Solution
You can in Python 3:
>>> *xs, x = [1, 2, 3, 4, 5, 6, 7]
>>> xs
[1, 2, 3, 4, 5, 6]
>>> x
7
Problem
Is it possible to assign to a list slice in one go, that would achieve the following as: ``` mylist = [1,2,3,4,5,6,7] xs = mylist[:-1] x = mylist[-1] xs == [1,2,3,4,5,6] x == 7 ``` I know I can write it like this: ``` xs,x = mylist[:-1], mylist[-1] ``` but I was wondering if it is possible to this any other way. Or have been spoilt by Haskell's pattern matching. something like `x,xs = mylist[:funky:slice:method:]`