Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ADD_COMMAND = "Add"
- INSERT_COMMAND = "Insert"
- REMOVE_COMMAND = "Remove"
- SWAP_COMMAND = "Swap"
- EXERCISE_COMMAND = "Exercise"
- END_COMMAND = "course start"
- initial_schedule_of_lessons_and_exercises = input().split(", ")
- while True:
- command_input = input().split(":")
- command = command_input[0]
- args = list(map(str, command_input[1:]))
- if command == END_COMMAND:
- for i in range(1, len(initial_schedule_of_lessons_and_exercises) + 1):
- print(f"{i}.{initial_schedule_of_lessons_and_exercises[i - 1]}")
- break
- elif command == ADD_COMMAND:
- if args[0] not in initial_schedule_of_lessons_and_exercises:
- initial_schedule_of_lessons_and_exercises.append(args[0])
- elif command == INSERT_COMMAND:
- lesson, index = args
- if lesson not in initial_schedule_of_lessons_and_exercises:
- initial_schedule_of_lessons_and_exercises.insert(int(index), lesson)
- elif command == REMOVE_COMMAND:
- eventual_exercise = f"{args[0]}-Exercise"
- if args[0] in initial_schedule_of_lessons_and_exercises:
- initial_schedule_of_lessons_and_exercises.remove(args[0])
- if eventual_exercise in initial_schedule_of_lessons_and_exercises:
- initial_schedule_of_lessons_and_exercises.remove(eventual_exercise)
- elif command == SWAP_COMMAND:
- first_title, second_title = args
- if first_title in initial_schedule_of_lessons_and_exercises and second_title in initial_schedule_of_lessons_and_exercises:
- exercise_1_for_swap, one = "", False
- exercise_2_for_swap, two = "", False
- exercise_one, exercise_two = f"{first_title}-Exercise", f"{second_title}-Exercise"
- if exercise_one in initial_schedule_of_lessons_and_exercises:
- initial_schedule_of_lessons_and_exercises.remove(exercise_one)
- exercise_1_for_swap = exercise_one
- one = True
- if exercise_two in initial_schedule_of_lessons_and_exercises:
- initial_schedule_of_lessons_and_exercises.remove(exercise_two)
- exercise_2_for_swap = exercise_two
- two = True
- position_first_title = initial_schedule_of_lessons_and_exercises.index(first_title)
- position_second_title = initial_schedule_of_lessons_and_exercises.index(second_title)
- initial_schedule_of_lessons_and_exercises[position_first_title], initial_schedule_of_lessons_and_exercises[position_second_title] = initial_schedule_of_lessons_and_exercises[position_second_title], initial_schedule_of_lessons_and_exercises[position_first_title]
- if one:
- initial_schedule_of_lessons_and_exercises.insert(position_second_title + 1, exercise_1_for_swap)
- if two:
- initial_schedule_of_lessons_and_exercises.insert(position_first_title + 1, exercise_2_for_swap)
- elif command == EXERCISE_COMMAND:
- lesson_title = args[0]
- exercise = f"{lesson_title}-Exercise"
- if lesson_title in initial_schedule_of_lessons_and_exercises and exercise not in initial_schedule_of_lessons_and_exercises:
- position = initial_schedule_of_lessons_and_exercises.index(lesson_title)
- initial_schedule_of_lessons_and_exercises.insert(int(position + 1), exercise)
- elif lesson_title not in initial_schedule_of_lessons_and_exercises:
- initial_schedule_of_lessons_and_exercises.append(lesson_title)
- initial_schedule_of_lessons_and_exercises.append(exercise)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement