def demo(lst, k):if k<len(lst):return lst[k:]+lst[:k]lst=[1,2,3,4,5,6]demo(lst,4)
lst[k:]是指index=4之后的数据,也就是[5,6],lst[:k]是指index=4之前的数据,也就是[1,2,3,4]