Python program to count the number of vowels digits words in a string
Answers
Answer:
str= "the quick brown fox jumps over the lazy dog 12908 and21893"
vowels="AaeEIiOoUu"
digits="0123456789"
word_count = len(str.split(" "))
print(word_count)
def check_vowel(vowel, string):
vowels_in_string = [each for each in string if each in vowel]
print(len(vowels_in_string))
check_vowel(vowels,str)
def check_digits(digits, string):
digits_in_string = [each for each in string if each in digits]
print(len(digits_in_string))
check_digits(digits,str)
Explanation:
string = input("Enter a string: ")
cv = 0
for i in string:
if i in "AEIOUaeiou":
cv = cv + 1
cw = 0
for i in string:
if i == " ":
cw = cw + 1
cd =0
for i in string:
if i.isdigit():
cd = cd + 1
print("Words: ", cw)
print("Vowels: ", cv)
print("Digits: ", cd)