all AI news
How to count the numbers of vowels and consonants in a sentence in python
March 24, 2024, 10:19 a.m. | Mangala
DEV Community dev.to
This program prompts the user to input a phrase, then counts the number of vowels and consonants present in that phrase, ignoring uppercase letters and considering only alphabetical characters.
def count_vowels_consonants(phrase):
vowels = 0
consonants = 0
# Converting the phrase to lowercase for easier comparison
phrase = phrase.lower()
# Defining a list of vowels
vowels_list = ['a', 'e', 'i', 'o', 'u']
# Iterating over each character in the phrase
for character in phrase:
# Checking if the character is …
characters comparison count developer numbers programming prompts python
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Data Architect
@ University of Texas at Austin | Austin, TX
Data ETL Engineer
@ University of Texas at Austin | Austin, TX
Lead GNSS Data Scientist
@ Lurra Systems | Melbourne
Senior Machine Learning Engineer (MLOps)
@ Promaton | Remote, Europe
Global Data Architect, AVP - State Street Global Advisors
@ State Street | Boston, Massachusetts
Data Engineer
@ NTT DATA | Pune, MH, IN