Problem with algorithm

Paddy paddy3118 at googlemail.com
Fri Apr 13 06:20:42 EDT 2007


On Apr 13, 8:16 am, "Jia Lu" <Roka... at gmail.com> wrote:
> > for m in test:
> >     for n in test:
> >         for o in test:
> >             for p in test:
> >                 print m+n+o+p
>
> Thanx for your anwser.
> But if I consider about a combination of over 26 letter's list just
> like:
> "abcdefssdzxcvzxcvzcv"
> "asllxcvxcbbedfgdfgdg"
> .....
>
> Need I write 26 for loops to do this?
>
> Thanx
>
> Jia LU
Try this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502199

You could then write something like:

import string
for thiscomb in comb2( *([string.lowercase]*26) ):
  ...

Mind you, it generates a lot of combinations.

- Paddy.




More information about the Python-list mailing list