rishiilluri

Untitled

Sep 2nd, 2022
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. input1 = str(input())
  2. p = int(input())
  3.  
  4. nums = input1.split(",")
  5.  
  6. n = len(nums)
  7. nums2 = [0]*n
  8. p = p%n
  9.  
  10. for i in range(len(nums)):
  11.     nums2[i] = nums[(n+i-p)%n]
  12.  
  13. print("Given list:", nums)
  14. print("Updated list after rotating by "+ str(p) + " positions:", nums2)
Advertisement
Add Comment
Please, Sign In to add comment