18 lines
488 B
Python
18 lines
488 B
Python
# Question: Write a Python program to check whether a given character is a vowel or consonant.
|
|
|
|
def main(char: str) -> None:
|
|
vowels = 'aeiou'
|
|
if char.lower() in vowels:
|
|
print(f"{char} is a vowel.")
|
|
elif char.isalpha():
|
|
print(f"{char} is a consonant.")
|
|
else:
|
|
raise ValueError("Invalid input. Please enter an alphabetic character.")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main('a')
|
|
main('b')
|
|
main('A')
|
|
main('1') # also works with a int
|