Advertisement
WupEly

Untitled

Sep 14th, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. from copy import copy
  2. alph = input()
  3. init_alph = alph
  4. alph = list(alph)
  5. rev_alph = copy(alph)
  6. shift = int(input())
  7.  
  8. if shift > 0:
  9. for i in range(shift):
  10. alph.insert(0, alph.pop())
  11. for i in range(shift):
  12. rev_alph.append(rev_alph.pop(0))
  13.  
  14.  
  15. else:
  16. shift = abs(shift)
  17. for i in range(shift):
  18. alph.append(alph.pop(0))
  19. for i in range(shift):
  20. rev_alph.insert(0, rev_alph.pop())
  21.  
  22. print("".join(rev_alph))
  23. print(init_alph)
  24. print("".join(alph))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement