Discussion about this post

User's avatar
Vinod VV's avatar

def count_vowels_consonants(text):

vowels = "aeiouAEIOU"

vowels_count = 0

consonants_count = 0

for char in text:

if char in vowels:

vowels_count += 1

elif char.isalpha():

consonants_count += 1

return vowels_count, consonants_count

text = input(f"Enter text or sentence to find number of vowels and consonants: ")

vowels_count, consonants_count = count_vowels_consonants(text)

print(f"The number of vowels in the string is: {vowels_count}")

print(f"The number of consonants in the string is: {consonants_count}")

Expand full comment
8 more comments...

No posts