Last active
October 5, 2017 18:38
-
-
Save juanarrivillaga/f7c32f60c3a5bc70b40130f1c201c8da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def split(n): | |
if len(n) < 1: | |
return '', '' | |
first = n[0] | |
rest = n[1:] | |
a, b = split(rest) | |
if first.islower() or first in ('_','.'): | |
return first + a, b | |
elif first.isupper() or first in (' ', '|'): | |
return a, first + b | |
else: | |
return a, b | |
# >>> split("'lMiED)teD5E,_hLAe;Nm,0@Dli&Eg ,#4aI?rN@T§&e7#4E #<(S0A?<)NT8<0'") | |
# ('lite_hemligare', 'MEDDELANDE INTE SANT') | |
# >>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment