Moves the specified amount of elements to the end of the list.
def offset(lst, offset):
return lst[offset:] + lst[:offset]
offset([1, 2, 3, 4, 5], 2) # [3, 4, 5, 1, 2]
offset([1, 2, 3, 4, 5], -2) # [4, 5, 1, 2, 3]
Python, List
Moves the specified amount of elements to the start of the list.
Python, List
Initializes a list containing the numbers in the specified range where start
and end
are inclusive with their common difference step
.
Python, List
Returns a list with n
elements removed from the end.