我的代码:
def isVowel(character):
vowels = 'aeiouAEIOU'
return character in vowels
def toPigLatin(String):
index = 0
stringLength = len(String)
consonants = ''
if isVowel(String[index]):
return String + '-ay'
else:
consonants += String[index]
index += 1
while index < stringLength:
if isVowel(String[index]):
return String[index:stringLength] + '-' +consonants + 'ay'
else:
consonants += String[index]
index += 1
return 'This word does contain any vowels.'
def printAsPigLatin(file):
return toPigLatin(file)
程序必须请求一个文件名才能将其转换为piglatin。文件每行包含一个单词。如何使用我的printAsPigLatin
函数向用户请求文件名以将其转换为pigltin?在
相关问题 更多 >
编程相关推荐