This problem is most easily illustrated in pseudo-code. I have a list like this:
linelist = ["a", "b", "", "c", "d", "e", "", "a"]
I would like to get it in the format:
questionchunks = [["a", "b"], ["c", "d", "e"], ["a"]]
My first attempt is this:
questionchunks = []
qlist = []
for line in linelist:
if (line != "" and len(qlist) != 0 ):
questionchunks.append(qlist)
qlist = []
else:
qlist.append(line)
My output is a little messed up though. I'd be grateful for any pointers I can get.