Advertisement
bl00dt3ars

01. World Tour

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