Write a program to count Vowels and Consonants in string.
Input
The input will be a single line containing a string s.
Output
The first line of output should contain no of Vowels in the given string
The second line of output should contain no of Consonants in the given string
Explanation
For example, if the given string is "Good Morning"
Vowels in the string "Good Morning" are "o, i" and their count is 4.
Remaining characters in the string are consonants their count is 7.
The First line of output is 4\nThe second line of output is 7.
Sample Input 1
Good Morning
Sample Output 1
4
7
Sample Input 2
welcome
Sample Output 2
3
4
#The input will be a single line containing a string s.
inputString=input("Enter string: ")
vowels=0
consonants=0
inputString=inputString.lower()
for l in inputString:
#check if the letter of the string is vowel
if(l == 'a' or l == 'e' or l == 'i' or l == 'o' or l == 'u' ):
vowels+=1
else:
#check if the letter of the string is consonant
if l != ' ' and l.isdigit()==False:
consonants+=1
#The first line of output should contain no of Vowels in the given string
print("Vowels: "+str(vowels))
#The second line of output should contain no of Consonants in the given string
print("Consonants: "+str(consonants))
Comments
Leave a comment