Skip to content

Instantly share code, notes, and snippets.

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