1
저는 현재 돼지 라틴어 코드를 Python으로 작업하고 있습니다. 두 가지 오류가 발생했습니다. 첫 번째 오류는 자음을 처리합니다. 단어가 두 개의 자음으로 시작하면 두 글자가 끝에오고 'ay'가 붙습니다. 그레이드은 adgray이됩니다. 내가 고정 무엇에파이썬 돼지 라틴어 - 자음 다루기
#Pig latin
pig= ("ay")
word = input("Enter a word: ")# prompt for a phrase and assign result to a variable
vowels="aeiou" # list of vowels
words = word.split()
# for word in words
for i in range(len(word)):# assign first letter of phrase to a string variable, for later use
if word[i][0] in vowels: # is first letter a vowel
print(word[i] + 'way') # if first letter is a vowel, print word + 'way'
elif word[i][1] in vowels:
print(word[i][1:]+word[i][0] + 'ay' # assign second letter of phrase to a string variable, for later use
else:
print(word[i]+ [1:]=('ay') # otherwise print word with first two letters moved to end & added 'ay'
raw_input()
당신이 @setholopo 감사 (그것은, 한 줄에 그들이 inputed 된 다만 방법을 모든 단어를 출력) lus, 나는 당신의 제안과 수정을 사용하여 작동하도록했다. * raw_input() *이 에러로 돌아 왔을 때, 나는 input()을 사용하여 작업 할 수 있었다. –아, 파이썬 3을 사용해야합니다. 2.7을 사용하고있었습니다. 2.7에 대해서 내가 말한 것은'input()'과'raw_input()'에 대해 (대부분) 사실이다. https://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input - and-input-in-python3-x – setholopolus