Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def print_state(stops_info):
- return stops_info
- data = input()
- stops = " "
- while not data == "Travel":
- command = data.split(":")[0]
- if command == "Add Stop":
- index = int(data.split(":")[1])
- next_stop = data.split(":")[2]
- if 0 <= index < len(stops):
- left_side = stops[:index]
- right_side = stops[index:]
- stops = left_side + next_stop + right_side
- print(print_state(stops))
- elif command == "Remove Stop":
- start_index = int(data.split(":")[1])
- end_index = int(data.split(":")[2])
- if 0 <= start_index < len(stops) and 0 <= end_index < len(stops):
- left_side = stops[:start_index]
- right_side = stops[end_index + 1:]
- stops = left_side + right_side
- print(print_state(stops))
- elif command == "Switch":
- old_string = data.split(":")[1]
- new_string = data.split(":")[2]
- if old_string in stops:
- stops = stops.replace(old_string, new_string)
- print(print_state(stops))
- else:
- stops = data
- data = input()
- print(f"Ready for world tour! Planned stops: {stops}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement