30 seconds of python

  Back to Home

offset

listbeginner

Moves the specified amount of elements to the end of the list.

Use lst[offset:] and lst[:offset] to get the two slices of the list and combine them before returning.

def offset(lst, offset):
  return lst[offset:] + lst[:offset]