0
나는 돼지 라틴어를 번역하고 단어를 가져 오는 파이썬에서 돼지 라틴어 함수를 만들려고합니다. 모든 자음을 첫 번째 모음까지 단어의 끝까지 이동시킨 다음 "ay"를 추가하여 영어 단어를 돼지 라틴어로 변환 할 수 있습니다 (예 : '안녕하세요'는 'ellohay'). 이 내 코드입니다 : 난 정말이에 대한 도움을 주셔서 감사합니다 것돼지 라틴어 파이썬
NameError: name 'consonant' is not defined
: 나는 그것을 실행하면
def pig_latin(word):
""" Returns the pig latin translation of a word. """
i=0
new_word = word
vowel = ["a", "e","i","o","u"]
while word[i] not in vowel:
word[i] = consonant
new_word = new_word[(i+1):] + consonant
i+=1
final_word = new_word + "ay"
return final_word
, 그것은 제공합니다.
감사합니다.