Consonant count in String - Python Language
16-11-2020 62 times
Write a Program in Python to accept a string from the user and count the consonant in it.
In this program, we should accept a string using input() method. Now read the line character by character and count the consonant characters (which are not in A, E, I, O, U) in it.
line=input("Enter a string") count=0 line=line.lower() for c in line: if(c.isalpha() and (c!="a" and c!="e" and c!="i" and c!="o" and c!="u")): count=count + 1 print("Total Consonant : ",count)