【发布时间】:2015-04-07 01:55:43
【问题描述】:
word = raw_input('Enter a word: ')
for i in word:
if i in ['a','e','i','u','A','E','I','O','o','U']:
word1 = i
break
else:
print i,
print ""
i = 0
while word[i]!=word1:
这是我遇到问题的地方。我需要在元音之前保存每个字母(或者我尝试过的 g )。这是猪拉丁语翻译的开端。在这个阶段,我试图翻转前缀和单词的其余部分。
g = word[i]
i = i+1
prefix = g + word1
print prefix
例子:
input - person
output - rsonpe
input - hello
output - llohe
input - pppat
output - tpppa
input - hhhhhelllllloool
output - llllllooolhhhhhe
我正在翻转第一个元音之前的字母,以及单词的其余部分。
【问题讨论】:
-
你试过追加到列表吗?
-
不,我可以在哪里使用 .append?
-
在你的 if 语句中。如果您写出输出的明确详细信息,您希望我可以更具体。
-
是的,请您说的更具体些。抱歉,我才刚入门。
-
然后使用示例数据和预期输出更新您的帖子。
标签: python while-loop