Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # list_rotation.py
- def list_rotation(lst,n):
- n = n%len(lst)
- return lst[n:]+lst[:n]
- print (list_rotation([1,6,9,0,8,-4,7,6],3)) # result=[0, 8, -4, 7, 6, 1, 6, 9]
- print (list_rotation([1,6,9,0,8,-4,7,6],-2)) # result=[7, 6, 1, 6, 9, 0, 8, -4]
- print (list_rotation([1,6,9,0,8,-4,7,6],12)) # result=[8, -4, 7, 6, 1, 6, 9, 0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement