Python dictionary music chord and notes
Write a program that asks the user for the key and the chord type and prints out the notes of the chord. Use a dictionary whose keys are the (musical) keys and whose values are the lists of steps.
music_key = input('Enter note C C# D D# E F F# G G# A A# B: ')
chord_type = input('Enter chord type: ')
sol = []
chord_type = input('Enter chord type: ')
sol = []
L = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B','C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#']
d = {'Major': [4, 7], 'Minor': [3,7], 'Dominant seventh': [4,7,10], 'Augmented fifth': [4,8], 'Minor seventh': [3,7,10], 'Minor fifth': [4,6], 'Major seventh': [4,7,11], 'Major sixth': [4,7,9], 'Diminished seventh': [3,6,10], 'Minor sixth': [3,7,9]}
c = d[chord_type]
sol.append(music_key)
index = L.index(music_key)
for i in range(len(c)):
sol.append(L[index + c[i]] )
print(sol)
Enter note C C# D D# E F F# G G# A A# B: B
Enter chord type: Major seventh
['B', 'D#', 'F#', 'A#']
Коментари
Постави коментар