Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- text = list(input())
- while True:
- command = input().split()
- if command[0] == "end":
- break
- elif command[0] == "Left":
- movement = int(command[1])
- for i in range(movement):
- removed = text.pop(0)
- text.append(removed)
- elif command[0] == "Right":
- movement = int(command[1])
- for i in range(movement):
- removed = text.pop()
- text.insert(0, removed)
- elif command[0] == "Insert":
- index = int(command[1])
- str_in = command[2]
- text.insert(index, str_in)
- elif command[0] == "Delete":
- del_start = int(command[1])
- del_end = int(command[2])
- del text[del_start: del_end+1]
- print("".join(text))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement