-2

I am asking how to check to which list belongs user input. Scenario: I have 2 lists, one for vowels and one for constants, the user inputs a letter to know whether it is a Vowel of Constant, however I don't know how to check whether it is that or that (validation).

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
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
karr7224
  • 23
  • 2

1 Answers1

1
if userinput in vowels:
   # it's a vowel
   ...
elif userinput in consonants:
   # it's a consonant
   ...
else:
   # it's neither
   ...
NPE
  • 486,780
  • 108
  • 951
  • 1,012