If you really want to move items, you can use modulo to cycle through the list and reassign items to their offset positions:
def shift(lst, shft=0): ln = len(lst) for i, ele in enumerate(lst[:]): lst[(i + shft) % ln] = ele return lst In [3]: shift( ['a','b','c','d'] , 1) Out[3]: ['d', 'a', 'b', 'c'] In [4]: shift( ['a','b','c','d'] , 2) Out[4]: ['c', 'd', 'a', 'b'] In [5]: shift( ['a','b','c','d'] , 3) Out[5]: ['b', 'c', 'd', 'a']
If you only need one shift, just slide the last item forward, expanding the list:
def shift(lst): lst[0:1] = [lst.pop(),lst[0]] return lst
Both of them modify the original list.
source share