Hackerss.com

hackerss
hackerss

Posted on

Python Count how many vowels has a string


def count_vowels(string):
    """
    Count how many vowels has a string
    """
    vowels = "aeiou"
    count = 0
    for char in string:
        if char in vowels:
            count += 1
    return count

def main():
    """
    Main function
    """
    string = input("Enter a string: ")
    print("The number of vowels is:", count_vowels(string))

if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)