Special Characters
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 stringExplanation
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.
# Special Characters
import string
vowels = set('AEIOUY')
consonants = set(string.ascii_uppercase)
consonants -= vowels
line = input().upper()
num_vow = 0
num_cons = 0
for ch in line:
if ch in vowels:
num_vow += 1
if ch in consonants:
num_cons += 1
print(num_vow)
print(num_cons)
Comments
Leave a comment