generate all combinations of a list (with variable output length)
thomas
tom at huno.net
Fri Jun 28 15:52:13 EDT 2002
hi,
i'm looking for a way to generate all possible combinations of all items
in a list. list = ["A","D","$","5","R"]
but i also want it to use one item several times or not at all and in no
particular order. the length of the string is 1-10. so a possible output
would be:
DD$
A5RD$D555
A
5RR$$A
DRRR55$5$A
...
i find it particualy difficult to tell python to use one item several
times or not at all, and the variable length thing. i don't want to
reinvent the wheel so someone probably has already a soultion for that
:) and if not someone can probably push me in some direction.
thx,
thomas
More information about the Python-list
mailing list