移动辅音的问题,如果单词在我的代码中以一个单词开头,那么辅音会移到最后。
def pig(word):
pig_const = 'ay'
pig_vowel = 'way'
word = word.lower()
if word[0] in 'aeiou':
word = word + pig_vowel
else:
last_const = ''
i = 0
#how many consonents in start
while last_const not in 'aeiouy':
i = i + 1
last_const = word[i]
word = word[i:] + word[0:i] + pig_const
return word
print((pig('happy')))