Created
August 12, 2020 14:27
-
-
Save Cyril-Pop/64832ae3c9686b15aad60413d2de9694 to your computer and use it in GitHub Desktop.
splitAtSequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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