[Tutor] Sequences of letter

Alan Gauld alan.gauld at btinternet.com
Tue Apr 13 02:07:07 CEST 2010

"Steven D'Aprano" <steve at pearwood.info> wrote

>>>> import itertools
>>>> for x in itertools.product('abc', 'abc', 'abc'):
> If you don't like the repeated 'abc' in the call to product(), it can be
> written as itertools.product(*['ab']*3) instead.

Nope, I think the repeated string is much clearer, and thus better,
than the cryptogram thanks very much! :-)

But I like the itertools solution.
I really, really, need to spend some time playing with itertools.

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list