我问如何检查哪个列表属于用户输入。场景:我有2个列表,一个用于元音,一个用于常量,用户输入一个字母以确定它是否是常量元音,但我不知道如何检查它是那个还是那个(验证)。 / p>
vowels = ['A','E','I'] # First list
constants = ['B','C','D'] # Second List
userinput = input('Type in letter which you want to check to whether it is a vowel or constant: ') # User types in the letter Which he wants to know to which category does it belong
答案 0 :(得分:1)
if userinput in vowels:
# it's a vowel
...
elif userinput in consonants:
# it's a consonant
...
else:
# it's neither
...