Advertisement
George_Ivanov05

0.1

Jul 27th, 2021
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. string_input = input()
  2. command = input().split(":")
  3.  
  4. while not command[0] == "Travel":
  5.     if command[0] == "Add Stop":
  6.         index = int(command[1])
  7.         string = command[2]
  8.         if 0 <= index < len(string_input):
  9.             string_input = string_input[: index] + string + string_input[index:]
  10.             print(string_input)
  11.     elif command[0] == "Remove Stop":
  12.         start_index = int(command[1])
  13.         end_index = int(command[2])
  14.         if 0 <= start_index < len(string_input) and 0 <= end_index < len(string_input):
  15.             string_input = string_input.replace(string_input[start_index: end_index + 1], "")
  16.             print(string_input)
  17.     elif command[0] == "Switch":
  18.         old_string = command[1]
  19.         new_string = command[2]
  20.         if old_string in string_input:
  21.             string_input = string_input.replace(old_string, new_string)
  22.             print(string_input)
  23.     command = input().split(":")
  24.  
  25. print(f"Ready for world tour! Planned stops: {string_input}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement