Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string = input()
- command = input()
- while command != "Reveal":
- data = command.split(":|:")
- command_name = data[0]
- if command_name == "InsertSpace":
- index = int(data[1])
- string = string[:index] + " " + string[index:]
- print(string)
- elif command_name == "Reverse":
- substring = data[1]
- reversed_string = substring[::-1]
- if substring in string:
- string = string.replace(substring, reversed_string)
- print(string)
- else:
- print(f"error")
- elif command_name == "ChangeAll":
- substring = data[1]
- replacement = data[2]
- if substring in string:
- for i in string:
- if i == substring:
- string = string.replace(i, replacement)
- print(string)
- command = input()
- print(f"You have a new text message: {string}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement