[Tutor] Recursive permutation

x x unigeek at hotmail.com
Fri Nov 19 19:12:06 CET 2004

Here is my 2 cents worth.
If I understand what you are trying to get you just need to take each string 
in Result and create all possible orders of it into a new list.

Result = ['']

def Combination(S):

    if len(S)>0:
        if S not in Result:
            for I in range(len(S)):
                str2= S[0:I] + S[I+1:len(S)]

    return Result


print Result

>>This code maks a permutation of the entire list (all the 3 digs), but how 
>>do I make the permutations of lower lists?
>>Going one down i seems easy: Remove alle the element one at a time and 
>>make a permultation of the rest. But going two down...

>>Like this:
>>Sting = 123
>>This give: 
>I think you're missing the list of length 0 ('') in your output...
>Tutor maillist  -  Tutor at python.org

Take charge with a pop-up guard built on patented Microsoft® SmartScreen 
  Start enjoying all the benefits of MSN® Premium right now and get the 
first two months FREE*.

More information about the Tutor mailing list