Skip to content

Instantly share code, notes, and snippets.

@Kcrong
Created February 3, 2018 09:16
Show Gist options
  • Save Kcrong/c52a315e18f66b73fa08ace56efaee87 to your computer and use it in GitHub Desktop.
Save Kcrong/c52a315e18f66b73fa08ace56efaee87 to your computer and use it in GitHub Desktop.
code2idx = {'c4':0, 'd4':1, 'e4':2, 'f4':3, 'g4':4, 'a4':5, 'b4':6,
'c8':7, 'd8':8, 'e8':9, 'f8':10, 'g8':11, 'a8':12, 'b8':13}
idx2code = {0:'c4', 1:'d4', 2:'e4', 3:'f4', 4:'g4', 5:'a4', 6:'b4',
7:'c8', 8:'d8', 9:'e8', 10:'f8', 11:'g8', 12:'a8', 13:'b8'}
# Or use dict comprehension
idx2code = {v: k for k, v in code2idx.items()}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment