If we have a list of strings in python and want to create sublists based on some special string how should we do?
For instance
Heres one idea. :)
def spec_split(seq,sep):
# Ideally this separator will never be in your list
odd_sep = "!@#$%^&*()"
# Join all the items with the odd separator and split
# anywhere the odd separator + separator + odd seperator meet
# This makes a list of items broken by the separator
jumble = odd_sep.join(seq).split(odd_sep+sep+odd_sep)
# split the remaining items broken by odd separators into sublists
return [item.split(odd_sep) for item in jumble]