pacho_the_python

Untitled

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