Advertisement
George_Ivanov05

0.1

Aug 9th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. string = input()
  2. command = input()
  3.  
  4. while command != "Reveal":
  5.     data = command.split(":|:")
  6.     command_name = data[0]
  7.     if command_name == "InsertSpace":
  8.         index = int(data[1])
  9.         string = string[:index] + " " + string[index:]
  10.         print(string)
  11.     elif command_name == "Reverse":
  12.         substring = data[1]
  13.         reversed_string = substring[::-1]
  14.         if substring in string:
  15.             string = string.replace(substring, reversed_string)
  16.             print(string)
  17.         else:
  18.             print(f"error")
  19.     elif command_name == "ChangeAll":
  20.         substring = data[1]
  21.         replacement = data[2]
  22.         if substring in string:
  23.             for i in string:
  24.                 if i == substring:
  25.                     string = string.replace(i, replacement)
  26.             print(string)
  27.     command = input()
  28. print(f"You have a new text message: {string}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement