Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- initial_schedule = input().split(", ")
- command = input().split(':')
- while command[0] != 'course start':
- action = command[0]
- lesson_title = command[1]
- if action == 'Add':
- if lesson_title not in initial_schedule:
- initial_schedule.append(lesson_title)
- elif action == 'Insert':
- index = int(command[2])
- if lesson_title not in initial_schedule:
- initial_schedule.insert(index, lesson_title)
- elif action == 'Remove':
- if lesson_title in initial_schedule:
- initial_schedule.remove(lesson_title)
- lesson_exercise = f'{lesson_title}-Exercise'
- if lesson_exercise in initial_schedule:
- initial_schedule.remove(lesson_exercise)
- elif action == 'Swap':
- lesson_title_second = command[2]
- if lesson_title in initial_schedule and lesson_title_second in initial_schedule:
- first_lesson_index = initial_schedule.index(lesson_title)
- second_lesson_index = initial_schedule.index(lesson_title_second)
- initial_schedule[first_lesson_index], initial_schedule[second_lesson_index] = \
- initial_schedule[second_lesson_index], initial_schedule[first_lesson_index]
- first_lesson_exercise = f'{lesson_title}-Exercise'
- second_lesson_exercise = f'{lesson_title_second}-Exercise'
- if first_lesson_exercise in initial_schedule:
- initial_schedule.remove(first_lesson_exercise)
- if second_lesson_index + 1 == len(initial_schedule):
- initial_schedule.append(first_lesson_exercise)
- else:
- initial_schedule.insert(second_lesson_index + 1, first_lesson_exercise)
- if second_lesson_exercise in initial_schedule:
- initial_schedule.remove(second_lesson_exercise)
- if first_lesson_index + 1 == len(initial_schedule):
- initial_schedule.append(second_lesson_exercise)
- else:
- initial_schedule.insert(first_lesson_index + 1, second_lesson_exercise)
- elif action == 'Exercise':
- if lesson_title not in initial_schedule:
- initial_schedule.append(lesson_title)
- lesson_exercise = f'{lesson_title}-Exercise'
- lesson_title_index = initial_schedule.index(lesson_title)
- if lesson_title_index + 1 < len(initial_schedule):
- initial_schedule.insert(lesson_title_index + 1, lesson_exercise)
- else:
- initial_schedule.append(lesson_exercise)
- else:
- lesson_title_index = initial_schedule.index(lesson_title)
- lesson_exercise = f'{lesson_title}-Exercise'
- if lesson_exercise not in initial_schedule:
- if lesson_title_index + 1 < len(initial_schedule):
- initial_schedule.insert(lesson_title_index + 1, lesson_exercise)
- else:
- initial_schedule.append(lesson_exercise)
- command = input().split(':')
- for count, value in enumerate(initial_schedule, start=1):
- print(f"{count}.{value}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement