diff --git a/Python/major_scale.py b/Python/major_scale.py index 4faae0e..8dd310d 100644 --- a/Python/major_scale.py +++ b/Python/major_scale.py @@ -16,29 +16,28 @@ HALF = 1 -def next_steps(note, steps=HALF): - idx = notes.index(note) +def next_note(start_note, steps=HALF): + idx = notes.index(start_note) for step in range(steps): idx = (idx + 1) % noteno return notes[idx] def major_scale(start): - out = [] - out.append(start) n = start + yield n for step in [WHOLE, WHOLE, HALF, WHOLE, WHOLE, WHOLE, HALF]: - n = next_steps(n, step) - out.append(n) - - return out + n = next_note(n, step) + yield n def main(): argp = argparse.ArgumentParser() argp.add_argument('note', help='Note starts the major scale') args = argp.parse_args() - print(major_scale(args.note)) + for note in major_scale(args.note): + print(note, end=' ') + print() if __name__ == "__main__":