Answer to Question #348828 in Python for johnwesley

Question #348828

python special characters vowels and consonants in string


write a program to count vowels and consonants in string


1
Expert's answer
2022-06-07T08:12:44-0400
a = list(input("Enter the string: "))


punctuation = " .,!?:;@#%&(){}[]$/-' ' "
vowels = "aeiouyAEIOUY"
vowels_list = []
consonants_list = []
list_clear = []
for key in a:
    if key in punctuation:
        a.remove(key)
for i in a:
    if i.strip() != '':
        list_clear.append(i)
for i in list_clear:
    if i in vowels:
        vowels_list.append(i)
    else:
        consonants_list.append(i)
print("Vowels - ", len(vowels_list))
print("Consonants - ", len(consonants_list))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS