[英]How do I properly use var[0] interpretation
我是Python的新手,並試圖制作Pig Latin Translator。 我的情況是你使用的Pig Latin的“類型”取決於元音和/或輔音在這個詞的乞討處。 這使我使用“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.
嘗試這個
first = eng[0]
rest = eng[1:]
if first in "aeiou":
# is a vowel
else:
# not a vowel, not necessarily a consonant
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.