Created
April 18, 2020 17:53
-
-
Save linuxluser/af07fbbb28821683e3a20a3234e45e8e to your computer and use it in GitHub Desktop.
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
#!/bin/python3 | |
import itertools | |
S = 'abc123xyz789' | |
L = [] | |
print(' Orig string:', S) | |
while S: | |
alpha = ''.join(itertools.takewhile(str.isalpha, S)) | |
L.append(alpha) | |
S = S[len(alpha):] | |
digit = ''.join(itertools.takewhile(str.isdigit, S)) | |
S = S[len(digit):] | |
L.append(digit) | |
print('All Split up:', L) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment