0
내 코드 :파이썬 문자열과 Piglatin
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
함수를 사용하여 사용자에게 파일 이름을 묻는 메시지를 돼지 머리글로 변환하도록 요청할 수 있습니까?
CodeAcademy에서 이와 비슷한 문제가 많이 발생합니다. –