I need to split a string in sequences of uppercase and lowercase characters. For example, the string "ABcdEFgh" should be converted into ["AB", "cd", "EF", gh"].
I've tried this:
string1 = "ABcdEFgh"
def split_upp_low(string):
for n, char in enumerate(string):
if char.isupper():
if string[n+1].islower():
list1 = string.split(char)
return list1
But the functions returns ['ABcdE', 'gh'] instead of ["AB", "cd", "EF", gh"]. How could I solve this?
Edit: In addition to the solution that schwobaseggl provided, is there any way of doing this without importing libraries?