This is an example of a form, I will try to explain it in words later. I have a list from line breaks ...
they say
[a, a, a, b, a, a, b, a, c, a, b, a, a, c, a, c, a]
where b is criterion 1 and c is criterion 2
I want to break it into a list as follows:
[a, a, a, [b, a, a, [b, a, c], a, [b, a, a, c], a, c], a]
So, I want to process the line in such a way that when I go through it, if the element meets the criteria 1, open a new list, if the element meets the criteria 2, close the list and return one level higher.
I tried to do something similar, but it does not work very well.
def sublist(self, l): for line in list: if not b: self.data.append(line) else: sublist(l[line:])
I saw a split list to equal the size of the list before stackoverflow, but not one hack in the sublist using a set of criteria.
I'm new to python, so I'm not too familiar with data structures and iterator tools.