How to Count the Number of Vowels in a string using Python?

PythonServer Side ProgrammingProgramming

Declare a string object containing all vowels.

>>> vowels='aeiou'

Set up a count variable initialize to 0

>>> count=0

Check if each character of input string belong to vowel string. If yes increment the count

>>> string='Hello How are you?'
>>> for s in string:
            if s in vowels: count=count+1

In the end display value of count

>>> count

Published on 24-Feb-2018 10:06:47