while True:
    if not any(str1.startswith(i) for i in prefixes):
        output.append(str1)
break
for p in prefixes:
    if str1.startswith(p):
        output.append(p)
str1 = str1.replace(p, '', 1)
Recursively split strings that contains a defined set of prefixes - Python