作者azulazure (独在异乡为异客)
看板Programming
标题[问题] ubbi dubbi翻译程式
时间Mon Mar 17 00:58:09 2008
我在试着写一个把英文翻成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