list - How to repeat the first characters of every word in a sentence timed by three in python? -



list - How to repeat the first characters of every word in a sentence timed by three in python? -

i want create function takes string (sentence) argument takes first word , saves every character konsonant first vowel (including vowel) , save in empty string. want take sec 1 , same thing... , on... , on...

ex. input -> "this good" output -> thithithi iii gogogo

this have came far:

def lang(text): alist=text.split() kons="nrmg" nytext=" " word in alist: tkn in word: if tkn in kons: nytext+=tkn else: nytext+=tkn nytext=nytext*3 nytext=nytext+"" break homecoming nytext print(lang("this good"))

what -> t t ti t t ti t t ti

what doing wrong?

any help appreciated!

thanks :)

so first thing if want maintain track of each word differently, need utilize variable(i called rettext) because each word should processed separately , results should collected in different variable.

secondly, if looking finding letters first vowel, need check if letter vowel or not. kons variable holds vowels , within of code, there

if not tkn in kons:

statement checks if tkn vowel or not. here total code:

def lang(text): alist=text.split() kons="aeiouaeiou" rettext="" word in alist: nytext="" tkn in word: if not tkn in kons: nytext+=tkn else: nytext+=tkn rettext += nytext*3 + " " break else: rettext += word*3 + " " homecoming rettext print(lang("this good"))

python list nested-loops

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -