I need to add a comma after a vowel or space in a string and append it to an array. I tried this but does not give me what I want. For e.g if I enter "a mambo jambo" output should be ['a', 'ma', 'mbo', 'ja', 'mbo'] .
This is my code:
text = input("Please enter text : ")
vowel = ["a", "e", "i", "o", "u"]
final_string = []
not_vowel = ""
a_vowel = ""
for text_in in text:
if text_in not in vowel:
not_vowel = text_in
if text_in in vowel:
a_vowel = text_in
final_string.append(f'{not_vowel}{a_vowel}')
print(final_string)
And this is the output after input "a mambo jambo":
['a', ' a', 'ma', 'ma', 'ma', 'ba', 'bo', ' o', 'jo', 'ja', 'ma', 'ba', 'bo']
what I want is
['a', 'ma', 'mbo', 'ja', 'mbo']