List rotation

M. Clift noone at here.com
Thu Sep 30 13:18:01 EDT 2004


Hi,

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',\
                                             'E','Eb','Ec','F','Fb','Fc',\
                                             'G','Gb','Gc','A','Ab','Ac',\
                                             'B','Bb','Bc']):

     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
case.

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

Thanks,

Malcolm





More information about the Python-list mailing list