2 ms·
If it's a list (and not a generator like `range`), then `l[1:-1]` will do.
by kmill 9y ago
If it's a list (and not a generator like `range`), then `l[1:-1]` will do.
- tomrod 9y agoOf course. Consider though: a, b, c = (l[0], l[1:-1], l[-1]) is also feasible, but I think it adds a bit of overhead