Counting Vowels

    0

    0

    Mahendra Kumar

    beginnerstrings

    Python program to count vowels in a string

    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))
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.