---
title: "Count the number of vowels in a string with example."  
description: "Count the number of vowels in a string with example."  
author: "Ravi Vishwakarma"  
published: 2025-09-03  
updated: 2025-09-03  
canonical: https://www.mindstick.com/forum/161901/count-the-number-of-vowels-in-a-string-with-example  
category: "python"  
tags: ["python-3.4", "python"]  
reading_time: 1 minute  

---

# Count the number of vowels in a string with example.

**[Count](https://www.mindstick.com/forum/157774/selecting-count-with-distinct) the number of vowels in a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) with example.**

## Replies

### Reply by Anubhav Sharma

```python
def count_vowels(text):
    vowels = "aeiouAEIOU"  #fix vowels
    count = 0              #hold given string vovel counting
    for char in text:      #interat the given text by charecter
        if char in vowels: #test the current charecter is in univershal vowel list
            count += 1     #if found then incresee the count value
    return count           #at return the count value

print('Vovels - ', count_vowels("Python Programming"))
```

## Output:

```plaintext
Vovels -  4
```

## Explanation:

- Loop through each character in the string.
- If the character is in the set of vowels, increase the count.
- `"Python Programming"` → vowels are `o, o, a, i` → total 4.

## Read More:

- [Write a function to check if a number is prime. with explanation](https://www.mindstick.com/forum/161900/write-a-function-to-check-if-a-number-is-prime-with-explanation)
- [What is the difference between @property and a normal method?](https://www.mindstick.com/forum/161899/what-is-the-difference-between-property-and-a-normal-method)


---

Original Source: https://www.mindstick.com/forum/161901/count-the-number-of-vowels-in-a-string-with-example

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
