counting using variable length string as base

Grimsqueaker Grimsqueaker13 at gmail.com
Thu Mar 27 02:15:41 EDT 2008


Hi, I'm fairly new to Python and to this list. I have a problem that
is driving me insane, sorry if it seems simple to everyone, I've been
fighting with it for a while. :))

I want to take a variable length string and use it as a base for
counting, eg. given the string 'abc' the  sequence would be:

a
b
c
aa
ba
ca
ab
bb
cb
...
ccc

Basically I want to find every possible order of every combination.
Its easy if you know how many characters there will be in your string
(use nested for loops), but I am stuck with the variable length
string. I think I have to use a generator but I'm not sure exactly
how.

Can anyone give me a pointer in the right direction?

Thanks
Daniel Browne



More information about the Python-list mailing list