Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input1 = str(input())
- p = int(input())
- nums = input1.split(",")
- n = len(nums)
- nums2 = [0]*n
- p = p%n
- for i in range(len(nums)):
- nums2[i] = nums[(n+i-p)%n]
- print("Given list:", nums)
- print("Updated list after rotating by "+ str(p) + " positions:", nums2)
Advertisement
Add Comment
Please, Sign In to add comment