Enharmonic Equivalents

Published by Joshua Señoron in

In music, notes can be written out in multiple ways (especially for notes on the black keys). Although these notes are spelled out differently, they still are the same note physically.

C# = Db, D# = Eb, F# = Gb, G# = Ab, A# = Bb

Given a musical note, create a function that returns its enharmonic equivalent. The examples below should make this clear.

Examples

get_equivalent("D#") ➞ "Eb"

get_equivalent("Gb") ➞ "F#"

get_equivalent("Bb") ➞"A#"

Notes

  • Note names will always be a capital letter followed by either # or b.
  • Remember that the note after G is A and vice versa.
Watch a quick demo on how Edabit works.