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)