Use slicing and append()
.
lst = [0, 1, 2, 3, 4, 5]
new_lst = lst[1:]
new_lst.append(lst[0])
You could also use new_lst.extend(lst[:1])
, though when the head slice is a single element, append(lst[0])
is probably slightly more efficient, since you don't have to construct another temporary list just to wrap a single value. lst[1:] + list[:1]
is probably the worst though, since it has to create yet another throw away list object compared to the extend()
version.