Advertisement
Guest User

Untitled

a guest
Oct 30th, 2021
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. message = input()
  2. message_lst = []
  3.  
  4. for i in message:
  5.     message_lst.append(i)
  6.  
  7. item = None
  8.  
  9. while True:
  10.     command = input().split('|')
  11.     if command[0] == 'Decode':
  12.         print(f"The decrypted message is: {''.join(message_lst)}")
  13.         break
  14.  
  15.     if command[0] == 'Move':
  16.         item = message_lst[0:int(command[1])]
  17.         del message_lst[0:int(command[1])]
  18.         for letter in item:
  19.             message_lst.append(letter)
  20.  
  21.     if command[0] == 'Insert':
  22.         firstPart = message_lst[:int(command[1])]
  23.         secondPart = message_lst[int(command[1]):len(message_lst)]
  24.         message_lst = []
  25.         for letter in firstPart:
  26.             message_lst.append(letter)
  27.         for letter in command[2]:
  28.             message_lst.append(letter)
  29.         for letter in secondPart:
  30.             message_lst.append(letter)
  31.  
  32.     if command[0] == 'ChangeAll':
  33.         message_lst[:] = [x if x != command[1] else command[2] for x in message_lst]
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement