我正在尝试使用 Python 制作一个 Pig Latin 翻译器。如果单词以元音开头,则应附加“方式”。如果单词以辅音开头,则应打印第一个字母移到末尾并附加“ay”的单词。Cat 应该打印 atcay,Apple 应该打印 appleway。但是,两者最终都有附加到末尾的方式。我解析并似乎找不到错误。我认为它与 elif 语句有关,也许它停在那里,但我是编程新手,不确定。
我究竟做错了什么?
print('Welcome to the Pig Latin translator!')
pyg = 'ay'
word = input('Enter a word: ')
word = word.lower()
if word.isalpha() == False: # Checks if string is empty and consists of only letters.
print('It seems that you did not enter a word, try again. ')
elif word[0] == 'a' or 'e' or 'i' or 'o' or 'u': # If first letter is a vowel
print(str(word) + 'way') # print variable word plus the string way
else:
newword = word + word[0] + pyg # If first letter is consonant(not vowel) and consists of only letters
print(newword[1:]) # print the word characters 1(not 0) through last