Question: This is the example form, I'll try to explain it in words later.
I have a list from breaking up a string...

say

```
[a, a, a, b, a, a, b, a, c, a, b, a, a, c, a, c, a]

```

where b is criteria 1 and c is criteria 2

I want to break it into a list like this:

```
[a, a, a, [b, a, a, [b, a, c], a, [b, a, a, c], a, c], a]

```

So I want to process the string such that when I go through it, if the item matches criteria 1, open a new list, if item matches criteria 2, close the list and return one level above.

I've tried to do something like this, but it's not working very well.

```
def sublist(self, l):
  for line in list:
    if not b:
    self.data.append(line)
  else:
    sublist(l[line:])       #<-----  not sure how to recurse it.

```

I've seen breaking list into equal sized list before on stackoverflow, but not one breaking into sublist using a set of criteria.

Answer: 
```
addlist = []
alllists = []
for item in mylist:
    if item == b:
       newlist = [item]
       addlist.append(newlist)
       alllists.append(addlist)
       addlist = newlist
    elif item == c:
       addlist.append(item)
       addlist = alllists.pop()
    else:
       addlist.append(item)

```

The above will work as long as your `b` and `c` delimiters are balanced; in particular, if you have an excess of `c`s, you will have a stack underflow.

While I frequently like recursive solutions, this has the advantage of making the stack explicit, which in this case, in my opinion, leads to easier to grok code.
In real recursion style you could do the following:

```
x = yourlist
i = 0
def lets_parse():
    global i
    fnlist = []
    while i < len(x)
        if x[i] == 'c':
            fnlist.append(x[i])
            i += 1
        return fnlist
        elif x[i] == 'b':
            i += 1
            f = lets_parse()
            f.insert(0, 'b')
            fnlist.append(f)
        else:
            fnlist.append(x[i])
            i += 1
return fnlist

print lets_parse()

```

Note the use of globals. A number of critics might object to it as bad coding style.