Two Stations' Play Logs

Before the LibrariesEasy+10 XP+10

Two Stations' Play Logs

Two radio stations each keep a log of the day's plays: a list of song titles, one entry per play, in the order they aired. The music director wants the songs that aired exactly once — not zero times, not twice — on each of the two stations.

Task: write played_once_on_both(log_a, log_b) that returns those titles as a list in alphabetical order (the order sorted gives).

  • Titles must match exactly, capital letters included: "Kites" and "kites" are different songs.
  • A song played twice on one station doesn't count, however many times the other station played it.
  • Either log may be empty. If no song qualifies, return [].

"Neon Tide" and "Glass Hour" aired on both stations as well, but each one was played twice on one of them.

Examples

log_a = ["Neon Tide", "Paper Moon", "Neon Tide", "Low Orbit", "Glass Hour"]
log_b = ["Paper Moon", "Glass Hour", "Glass Hour", "Low Orbit", "Neon Tide"]
returns ['Low Orbit', 'Paper Moon']
log_a = ["Salt Road", "Ember", "Ember"]
log_b = ["Ember", "Salt Road"]
returns ['Salt Road']

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run