the python way?
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Tue Jun 7 15:13:02 EDT 2005
Andrew Dalke wrote:
> Reinhold Birkenfeld wrote:
>> To make it short, my version is:
>>
>> import random
>> def reinterpolate2(word, vocals='aeiouy'):
>> wlist = list(word)
>> random.shuffle(wlist)
>> vees = [c for c in wlist[::-1] if c in vocals]
>> cons = [c for c in wlist[::-1] if c not in vocals]
>
> Why the [::-1]? If it's randomly shuffled the order isn't important.
I wanted to keep compatibility with Groops' version so that I could test
that my one works right. Since he did list.pop() it was necessary.
>> short, long = sorted((cons, vees), key=len)
>> return ''.join(long[i] + short[i] for i in range(len(short))) + ''.join(long[len(short):])
>
> All the cool kids are using 2.4 these days. :)
Yep, it's the best way to advertise for its cool features ;)
Reinhold
More information about the Python-list
mailing list