yet another noob question

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Mon Aug 14 07:38:00 EDT 2006


Gerard Flanagan:

> mod5 = ['1','2','3','4','5']
> X = [ ''.join([a,b,c,d,e])
>       for a in mod5
>       for b in mod5
>       for c in mod5
>       for d in mod5
>       for e in mod5 ]

A modified version of your one is the faster so far:

v = "12345"
r = [a+b+c+d+e for a in v for b in v for c in v for d in v for e in v]

Bye,
bearophile




More information about the Python-list mailing list