因此,例如,如果我输入bob,它应该给我obb。同样,类似plank的东西应该给我ankpl

s = input("What word do you want translated?")
first = s[0]
vowel = "aeiou"
for i in range (1, len(s)):
     if first in vowel:
        s = s + "way"
        print (s)
else:
        s = s[1:] + s[0]
        print (s)


目前,这只给我lankp代替plank
谢谢!

最佳答案

实际上,它可以变得更简单:

s = raw_input("What word do you want translated?").strip()
vowel = set("aeiou")
if vowel & set(s):
    while s[0] not in vowel:
        s = s[1:] + s[0]
    print s
else:
    print "Input has no vowels"

关于python - Python程序连续将辅音移到字符串的末尾,直到第一个字母为元音,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19828561/

10-10 20:56