python special characters vowels and consonants in string
write a program to count vowels and consonants in string
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))
Comments
Leave a comment