Guest User

Secret Chat - Fundamentals Final Exam Retake - 10 April 2020

a guest
Jul 9th, 2020
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. string_messages = input()
  2. while True:
  3.     command = input().split(":|:")
  4.     if command[0] == "Reveal":
  5.         print(f"You have a new text message: {string_messages}")
  6.         break
  7.     if command[0] == "InsertSpace":
  8.         index_command = int(command[1])
  9.         string_messages = string_messages[:index_command] + ' ' + string_messages[index_command:]
  10.         print(string_messages)
  11.     elif command[0] == "Reverse":
  12.         substring = command[1]
  13.         if substring in string_messages:
  14.             string_messages = string_messages.replace(substring, '', 1)
  15.             string_messages += substring[::-1]
  16.             print(string_messages)
  17.         else:
  18.             print("error")
  19.     elif command[0] == "ChangeAll":
  20.         substring, replacement = command[1], command[2]
  21.         if substring in string_messages:
  22.             string_messages = string_messages.replace(substring, replacement)
  23.             print(string_messages)
Add Comment
Please, Sign In to add comment