List rotation

M. Clift noone at
Thu Sep 30 19:18:01 CEST 2004


I think this might nearly be it;

Chords = ['C','Db','E','Gc','Ab']

def rotate_letters(items, trans=0, rotation=['C','Cb','Cc','D','Db','Dc',\

     return [rotation[(rotation.index(item)+trans) % len(rotation)]
             for item in items]

print TUNE
print rotate_letters((Chords), trans=2)

The problem is this gives;

['Cc', 'E', 'Ec', 'Ab', 'B']

Fine you say, thats what you asked for. What it should read is;

['D', 'Eb','F','Ac','Bb']

So the first capital letters need to transpose, but not the second lower

Any ideas?

For the musicians amoungst you the lower case refers to the inversion. i.e.
none = root, b = first and c of course = second



More information about the Python-list mailing list