text = "This is a small example Text, showcasing my desired output."
def split_sentence(texto):
split_texto = texto.split()
comb_st = [] # Combinaciones split
i = 0
for st in split_texto:
comb_st.append(st)
if split_texto == split_texto[-1]:
break
else:
add_st = ""
for cs2 in split_texto[i + 1: ]:
add_st += " " + cs2
add_st = add_st.lstrip()
comb_st.append(st + " " + add_st)
i += 1
# for i in range(len(comb_st)):
# comb_st[i] = comb_st[i].split()
return comb_st
comb_split_texto = split_sentence(text)
OUTPUT:
This
This is
This is a
This is a small
This is a small example
This is a small example Text,
This is a small example Text, showcasing
This is a small example Text, showcasing my
This is a small example Text, showcasing my desired
This is a small example Text, showcasing my desired output.
is
is a
is a small
is a small example
is a small example Text,
is a small example Text, showcasing
is a small example Text, showcasing my
is a small example Text, showcasing my desired
is a small example Text, showcasing my desired output.
a
a small
a small example
a small example Text,
a small example Text, showcasing
a small example Text, showcasing my
a small example Text, showcasing my desired
a small example Text, showcasing my desired output.
small
small example
small example Text,
small example Text, showcasing
small example Text, showcasing my
small example Text, showcasing my desired
small example Text, showcasing my desired output.
example
example Text,
example Text, showcasing
example Text, showcasing my
example Text, showcasing my desired
example Text, showcasing my desired output.
Text,
Text, showcasing
Text, showcasing my
Text, showcasing my desired
Text, showcasing my desired output.
showcasing
showcasing my
showcasing my desired
showcasing my desired output.
my
my desired
my desired output.
desired
desired output.
output.