string - Python function input with variable length -
this kind of vague, i'm in process of making english-to-kong translator. kong, being "language" word "grape" turns "gong rong pong e", requires split input word, in case grape, each individual letter, check if it's vowel, , if not append "ong" it.
i came across problem way if knew number of letters in word, because ended running each letter through function checked if vowel, , if not appended "ong". that, did first = word[0]
, second = word[1]
, , on, , ran through vowelchecker
function.
is there way have word number of letters go through function , still come out properly?
you can loop through string list of letters.
for example:
word = 'grape' in word: #do
here, in each iteration of loop, a
set value of current letter of word
string. don't need know length ahead of time because loop run until has looped through letters (unless write condition break loop).
Comments
Post a Comment