Python Program to Count Vowels and Consonants in a String

def vowel_count(string):
  vowels = ['a', 'e', 'i', 'o', 'u']
  return len([i for i in string if i in vowels])

3.44
9

                                    
pineapple

3.44 (9 Votes)
0
4
7

                                    Good Morning

4 (7 Votes)
0
3.5
2
Jesse McGrew 105 points

                                    # Python Program to Count Vowels and Consonants in a String

str1 = input("Please Enter Your Own String : ")
vowels = 0
consonants = 0

for i in str1:
    if(i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u'
       or i == 'A' or i == 'E' or i == 'I' or i == 'O' or i == 'U'):
        vowels = vowels + 1
    else:
        consonants = consonants + 1
 
print("Total Number of Vowels in this String = ", vowels)
print("Total Number of Consonants in this String = ", consonants)

3.5 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
Write a menu driven program in python using text file to (a)To count the vowels and consonants(b)To count the no. of words “to” in the file(c)To display the line that begin with a given letter Write a program that asks the user for a sentence and then counts the number of vowels (a, e, i, o, u) in the sentence input line words and output vowel characters and consonant print the count of consonants in a given string which comes after oval in python output percentage of vowels and consonants in a given file in python Write a program that takes in user input and stores the variable in a String. Then, the program will print how many vowels, (counting lower case and upper case), were in the provided String. count the number of vowels in below sentence the vowels and consonants in the text are count "Write a function that read charactor data from file and count vowel in each name (Use dynamic regrow concept wisely)" rite a function which accepts a string and returns the number of capital letters, vowels, numbers and special characters. How do you count a number of vowels and consonants in a given string? find number of vowels in string java Count and display the number of vowels, consonants, uppercase, lowercase characters in string. Given a sentence containing only uppercase/lowercase english alphabets and spaces, you have to count the number of words, vowels and consonants. java program to return the no of vowels in a string vowels and non vowels print 3. Program to count number of vowels and consonants in a given line of text. firts 2 digits are vowels count vowel consonant write a python program to count the number of vowels,consonants,digits and special characters. write a program to find the number of vowels and the number of consonants in the file. Write a Java method to count all vowels in a string. code to count number of vowels and consonants write a program to count the number of vowel in a word in the given sentence in java java program to find no of vowels in a word from sentence java program to read text file and count vowels, consonants and digits in the text file Write a program to find out all vowels in one constructer if input is string and find the sum of all digits in another constructer if the input is number. javascript read from a file on pc and count vowels, consonants and digits javascript read notepad file and display vowels, consonants and digits python code that counts the number of vowels, constants, and charecters string output the no. of vowels get the percentage of vowels from string java python program to print vowels, consonants, spaces in a string Write a menu driven program in python using text file to (a)To count the vowels and consonants(b)To count the no. of words “to” in the file(c)To display the line that begin with a given letter Write a menu driven program in python using text file to To count the vowels and consonants Q2: Identify the count of Vowels (A, E, I, O, U) and unique consonants. If the string consist of any digit then write that string into log file python. Write a program that takes a string as input and counts the number of vowels in it. python program to accept a line of text and find the number of characters, number of vowels, and number of blank spaces in the input line 2. . Program to count no of ‘p’ in the string pineapple. def lettercount( ): word = 'pineapple' count = 0 for letter in word: if letter == 'p' count = cout + 1 print(‘Total no of ‘p’ in the string pineapple’,count) Find the errors and output. check for no of vowel in a string Python Enter an input string A. Write a program to find the number of vowels, consonants, digits and whitespace characters in string A. find all the vowels and consonants in a given string Write a program, which allows a user to enter a sentence, and then counts the number of vowels in that sentence. Hint vowels are: a,e,i,o,u. in vb.net count vowels and consonants no special characters or numbers in javascript Create a program that will count the number of vowels, consonants and words in a sentence using arrays Considering only the alphabetical characters, consonants having the value oftheir ASCII codes, and vowels having the inverse value of their ASCII codes,what is the sum of the sentence Python Program to Count Vowels and Consonants in a String
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source