def countVowels(string):
          num_vowels=0
          # to count the vowels
          for char in string:
              if char in "aeiouAEIOU":
                 num_vowels = num_vowels+1
          return num_vowels
      # take input
      string = input('Enter any string: ')
      # calling function and display result
      print('No of vowels =',countVowels(string))
      
      Python language logo

      Counting Vowels

      beginner
      strings

      Python program to count vowels in a string

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.