Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MOVE_LETTERS = "Move"
- INSERT_VALUE = "Insert"
- CHANGE_ELEMENT = "ChangeAll"
- def move_letters_of_code(secret_message, *args):
- index_of_movement = int(args[0])
- left_part = secret_message[:index_of_movement]
- right_part = secret_message[index_of_movement:]
- secret_message = right_part + left_part
- return secret_message
- def insert_value_in_message(secret_message, *args):
- index_of_inserting = int(args[0])
- value_to_insert = args[1]
- part1 = secret_message[:index_of_inserting]
- part2 = secret_message[index_of_inserting:]
- secret_message = part1 + value_to_insert + part2
- return secret_message
- def change_elements_in_secret_message(secret_message, *args):
- substring = args[0]
- replacement = args[1]
- secret_message = secret_message.replace(substring, replacement)
- return secret_message
- def main():
- encrypted_message = input()
- command = input().split("|")
- while command[0] != "Decode":
- action = command[0]
- args = command[1:]
- if action == MOVE_LETTERS:
- encrypted_message = move_letters_of_code(encrypted_message, *args)
- elif action == INSERT_VALUE:
- encrypted_message = insert_value_in_message(encrypted_message, *args)
- elif action == CHANGE_ELEMENT:
- encrypted_message = change_elements_in_secret_message(encrypted_message, *args)
- command = input().split("|")
- print(f"The decrypted message is: {encrypted_message}")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement