Python Online Compiler
Example: Python program to check whether input character is vowel or consonant using if-else
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python program to check whether input character is vowel or consonant using if-else print("Enter a character to check: ", end="") random_character, lowercase, uppercase = str(input()), 0, 0 # isalpha() method will check # whether character is alphabetic or non-alphabetic if (random_character and random_character.isalpha()): # it will be return 1 # if input character matched with these small characters lowercase = random_character == 'a' or random_character == 'e' or random_character == 'i' or random_character == 'o' or random_character == 'u' # it will be return 1 # if input character matched with these capital characters uppercase = random_character == 'A' or random_character == 'E' or random_character == 'I' or random_character == 'O' or random_character == 'U' if (lowercase or uppercase): print("\n'", random_character, "' is a vowel character.") else: print("\n'", random_character, "' is a consonant character.") else: print("\nSorry, You entered a Non-Alphabetic character!")
U
Output
Clear
ADVERTISEMENTS