Problem 2 - Minor Key Here is a list of musical notes, written with flats (rather than sharps): CDb, D, Eb, E, F, Gb,G,Ab. ABb. B, C in the next octave) Observe that not all notes have flats, Le.Cflat is actually B which is not a black key on the piano for instance The harmonic minor scale is composed of the following sequence of steps: Step] [ Step) | Step) [Step] [13 Step] [1% Step] [ Step] For instance, the Charmonic minor scale is C, D, E, F, G, A.B.C. Each musical "half step" is a single step through the list, the name half-step predates computers so you have to forgive musicians a little. The Eb harmonic minor scale is Eb F Gb Ab Bb BDE The G harmonic minor scale is GABb CDE5 GbG Define a list: MUSICAL NOTES - ['c', D\u2660', 'D', 'E\0266d', TE", "Gu2663', 'G', A\u266d', 'A', '\u2660". Note that \u266d' is the unicode for the flat symbol Allow the user to enter starting notes like: "E* or "B flat" or "flat" You will have to calculate the starting note from this, or if it's not a note, for instance if they enter "R" Then display the harmonic minor scale starting at that note, or an error message indicating that it is not a note. When the user enters "quit then stop asking for notes and exit the program,
My suggestion is that you break this problem down into parts: 1) Translate the input into the musical notation by creating a Thelper function' which takes as a parameter the user's input and outputs the proper note, meaning it will replace 'flat' with b and remove the space, so that it matches the description in the list of strings. 2) Compute the starting index in the list of musical notes or determine that the starting index doesn't exist because the note isn't a real note. I use another helper function for this purpose. 3) Calculate the scale itself in a slightly bigger function but then return it as a list. 4) Outside of your function, implement a main loop where you will join the answer together and output it. This is generally how programmers think about problems. We attempt to break each problem into subproblems which we can write small functions to solve. Then we put those functions together and get our final results.
Sample Output linux5[109] python3 minor_key py Enter a starting note (D. E flat): G GAB CD EGG Enter a starting note (C, D flat): A ABCDETA A Enter a starting note (c, Dalat): A flat A B B D E EGA Enter a starting note (C, D flat): flat There is no starting note R. Enter a starting note (C, D flat): quit linux5[110]\ python3 minor_key.PY Enter a starting note (D, E flat): C CDEFGABC Enter a starting note (C, D flat): D DEFGAB DD Enter a starting note (C, D flat): E flat EFG A B BDE Enter a starting note c, flat): G GAB CD EGG Enter a starting note (C, D flat): flat DEEA ACD Enter at ting note (C, D flat): quit