char = input("Enter a character: ").lower()
if char in 'aeiou':
print("It's a vowel.")
else:
print("It's a consonant.")
#source code --> clcoding.com
Code Explanation:
Taking Input from the User
char = input("Enter a character: ").lower()
The program asks the user to enter a character.
Since input() takes input as a string, it is stored in the variable char.
.lower() is used to convert the input into lowercase so that it works for both uppercase and lowercase letters.
Checking if the Character is a Vowel
if char in 'aeiou':
print("It's a vowel.")
The if condition checks if the entered character exists in the string 'aeiou'.
If true, it means the character is a vowel, so the program prints:
It's a vowel.
If the Character is NOT a Vowel, It’s a Consonant
else:
print("It's a consonant.")
If the character is not found in 'aeiou', it means the character is a consonant.
The program prints:
It's a consonant.
0 Comments:
Post a Comment