Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_vowels_consonants():
- text = "How many vowels and consonants are in this sentence?"
- vowels_count = 0
- consonants_count = 0
- for char in text:
- if char in ("aeiou"):
- vowels_count = vowels_count + 1
- elif char.isalpha():
- consonants_count = consonants_count + 1
- return vowels_count, consonants_count
- vowels_count, consonants_count = count_vowels_consonants()
- print(f"The number of vowels in the string is: {vowels_count}")
- print(f"The number of consonants in the string is: {consonants_count}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement