Solution and Explanation:
the_notes = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B'] #original list
def get_scale(choice): #function to get the major diatonic scale
steps=[1,1,.5,1,1,1,.5] #separate list for steps
size=None
for i in range(0,12): #loop to find out the index of the note entered
if(the_notes[i]==choice):
size =i
break
new_notes=the_notes[size:] + the_notes[:size]
#the above statement rotate the list so that the entered note can become the first note in the new list(i.e new notes)
index =0 #
scale="" #a string to store the major diatonic scale
for i in range(0,7):
scale+=new_notes[index]+" "
if(steps[i]==1):
index = index+2
else:
index=index+1
return scale
#main block
while(1):
choice=input("What scale do you want or Q to quit? ")
if(choice=='Q'):
break
elif(choice in the_notes):
print(get_scale(choice))
else:
print("That is not a note")