Skip to content

Instantly share code, notes, and snippets.

@linuxluser
Created April 18, 2020 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linuxluser/af07fbbb28821683e3a20a3234e45e8e to your computer and use it in GitHub Desktop.
Save linuxluser/af07fbbb28821683e3a20a3234e45e8e to your computer and use it in GitHub Desktop.
#!/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