Advertisement
eNeRGy90

Untitled

Feb 1st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. text = list(input())
  2.  
  3. while True:
  4.     command = input().split()
  5.     if command[0] == "end":
  6.         break
  7.     elif command[0] == "Left":
  8.         movement = int(command[1])
  9.         for i in range(movement):
  10.             removed = text.pop(0)
  11.             text.append(removed)
  12.     elif command[0] == "Right":
  13.         movement = int(command[1])
  14.         for i in range(movement):
  15.             removed = text.pop()
  16.             text.insert(0, removed)
  17.     elif command[0] == "Insert":
  18.         index = int(command[1])
  19.         str_in = command[2]
  20.         text.insert(index, str_in)
  21.     elif command[0] == "Delete":
  22.         del_start = int(command[1])
  23.         del_end = int(command[2])
  24.         del text[del_start: del_end+1]
  25. print("".join(text))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement