Skip to content

Instantly share code, notes, and snippets.

@Cyril-Pop
Created August 12, 2020 16:16
Show Gist options
  • Save Cyril-Pop/09a7d2d09be7cf36723aaed007ff86d5 to your computer and use it in GitHub Desktop.
Save Cyril-Pop/09a7d2d09be7cf36723aaed007ff86d5 to your computer and use it in GitHub Desktop.
var2 = ['a','b','b','c','d','e', 'g', 'a', 'b','c', 'a','b','c','e']
def splitChar2(lst):
temp = []
for idx, x in enumerate(lst):
try:
if lst[idx + 1] != 'a':
temp.append(x)
else:
temp.append(x)
yield temp
temp = []
splitChar2(lst[idx + 1:])
except IndexError:
temp.append(x)
yield temp
varw =[ x for x in splitChar2(var2)]
print (varw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment