Write a function that takes as input an English sentence (a string) and prints the total
number of vowels and the total number of consonants in the sentence. The function returns
nothing. Note that the sentence could have special characters such as dots, dashes,
and so on.
write a python program please.
str1 = input("Please Enter Your String : ")
vowels = 0
consonants = 0
str1.lower()
for i in str1:
if(ord(i) == 65 or ord(i) == 69 or ord(i) == 73
or ord(i) == 79 or ord(i) == 85
or ord(i) == 97 or ord(i) == 101 or ord(i) == 105
or ord(i) == 111 or ord(i) == 117):
vowels = vowels + 1
elif((ord(i) >= 97 and ord(i) <= 122) or (ord(i) >= 65 and ord(i) <= 90)):
consonants = consonants + 1
print("Total Number of Vowels in this String = ", vowels)
print("Total Number of Consonants in this String = ", consonants)
Get Answers For Free
Most questions answered within 1 hours.