Possible Duplicate:
Split a list into nested lists on a value
I have a list like this:
['jj01','gg01',',','yy01','hh01',',','yy04','uu01']
How would I split this list to its elements — splitting on ',' like this:
[['jj01','gg01'],['yy01','hh01'],['yy04','uu01']]
Thanks in advance.
One possible ‘pythonic’ way to do this:
which can be combined into the one-liner:
As pointed out in the comments, this solution will work only if the contents of the list are strings.