simple recursion help

drs drs at
Sat Oct 23 21:37:10 CEST 2004

Hi,  I am trying to find all lists of length x with elements a, b, and c.
To this end, I have created the class below, but it is not quite working and
I am having trouble figuring out what to change.  Does anyone have any

class c:
    def __init__(self):
        self.traits = 4 # number of list elements
        self.types = 3  # elements can be 0, 1, or 2

    def a(self):
        l = []
        for i in range(self.traits):
        return l

    def b(self, s):
        if len(s) == self.types:
            return s
        for i in range(self.traits):
            return self.b(s + str(i))

i = c()
lst = i.a()

Thanks in advance,


More information about the Python-list mailing list