我是Python新手并尝试制作Pig Latin Translator。我的情况是"类型"你使用的猪拉丁语取决于元音和/或辅音在乞讨的位置。这使我使用像" my_var [0] = new_var"这样的东西。我的问题是我试图解释原始输入中的变量是否包含某些字符串字符,例如" a"," x"等等。如果有人能纠正我的话代码,这将是非常棒的!感谢您提前帮助:)!
print "Hello. Welcome to the Pig Latin translator! :)"# Welcome MSG
eng = raw_input("Please enter in a word in English to translate to Pig Latin.")#Asking the user to input something
if eng[0] == "a" + "b"+"c" :# I'm say if the first letter equals a constant.
答案 0 :(得分:0)
试试这个
first = eng[0]
rest = eng[1:]
if first in "aeiou":
# is a vowel
else:
# not a vowel, not necessarily a consonant