[問題] ubbi dubbi翻譯程式
我在試著寫一個把英文翻成ubbi dubbi的程式
用的是python
ubbi dubbi就是在英文字的第一個母音前加入ub
例如: hello -> hubello, apple -> ubapple, three -> threbee
我一開始寫的程式在翻譯一個單字時沒有問題
但在翻譯句子時就出現了麻煩
以下是我寫的程式
vowel = "aeiouAEIOU"
inputline = sys.stdin.readline()
inputwords = str.split(inputline)
ubbiword = ""
for word in inputwords:
while word[0] not in vowel:
ubbiword += word[0]
word = word[1:]
word = ubbiword + "ub" + word
可是這樣寫的話
會出現這樣的結果
today is sunday -> tuboday tubis tsubunday
我要怎麼樣才可以不讓第一個字母出現在每一個字前面呢?
先謝謝大家了
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 69.143.181.102
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章