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":
- title = command[1]
- if command[0] == "Add":
- if title not in initial_schedule:
- initial_schedule.append(title)
- elif command[0] == "Insert":
- index = int(command[2])
- if 0 <= index < len(initial_schedule):
- if title not in initial_schedule:
- initial_schedule.insert(index, title)
- elif command[0] == "Remove":
- if title in initial_schedule:
- initial_schedule.remove(title)
- title_exercise = f'{title}-Exercise'
- if title_exercise in initial_schedule:
- initial_schedule.remove(title)
- elif command[0] == "Exercise":
- if title not in initial_schedule:
- initial_schedule.append(title)
- title_exercise = f'{title}-Exercise'
- title_index = initial_schedule.index(title)
- if title_index + 1 < len(initial_schedule):
- initial_schedule.insert(title_index + 1, title_exercise)
- else:
- initial_schedule.append(title_exercise)
- else:
- title_index = initial_schedule.index(title)
- title_exercise = f'{title}-Exercise'
- if title_exercise not in initial_schedule:
- if title_index + 1 < len(initial_schedule):
- initial_schedule.insert(title_index + 1, title_exercise)
- else:
- initial_schedule.append(title_exercise)
- elif command[0] == "Swap":
- title2 = command[2]
- if title in initial_schedule and title2 in initial_schedule:
- i = initial_schedule.index(title)
- j = initial_schedule.index(title2)
- initial_schedule[i], initial_schedule[j] = \
- initial_schedule[j], initial_schedule[i]
- title_exercise = f'{title}-Exercise'
- title2_exercise = f'{title2}-Exercise'
- if title_exercise in initial_schedule:
- initial_schedule.remove(title_exercise)
- if j + 1 == len(initial_schedule):
- initial_schedule.append(title_exercise)
- else:
- initial_schedule.insert(j + 1, title_exercise)
- if title2_exercise in initial_schedule:
- initial_schedule.remove(title2_exercise)
- if i + 1 == len(initial_schedule):
- initial_schedule.append(title2_exercise)
- else:
- initial_schedule.insert(i + 1, title2_exercise)
- command = input().split(":")
- for lesson in range(len(initial_schedule)):
- print(f"{lesson + 1}.{initial_schedule[lesson]}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement