
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
Python program to count the number of vowels using sets in a given string
In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a string, we need to count the number of vowels using sets in a given string.
Here we are traverse through the whole string and check whether each character is a vowel or not and increment the count.
Now let’s observe the concept in the implementation below −
Example
def vowel_count(str): count = 0 #string of vowels vowel = "aeiouAEIOU" for alphabet in str_: #check whether character is a vowel or not if alphabet in vowel: count = count + 1 print("No. of vowels in the given string:", count) # Driver code str_ = "Tutorialspoint" vowel_count(str)
Output
No. of vowels in the given string : 6
All the variables are declared in the local scope and their references are seen in the figure above.
Conclusion
In this article, we have learned about how we can count the number of vowels in a given string using sets.
- Related Articles
- Python program to count number of vowels using set in a given string
- Python program to count the number of vowels using set in a given string
- How to Count the Number of Vowels in a string using Python?
- Java program to count the number of vowels in a given sentence
- C++ Program to count Vowels in a string using Pointer?
- C# Program to count number of Vowels and Consonants in a string
- To count Vowels in a string using Pointer in C++ Program
- Java Program to count vowels in a string
- C# Program to count vowels in a string
- Count the number of vowels occurring in all the substrings of given string in C++
- Java Program to count all vowels in a string
- Count the pairs of vowels in the given string in C++
- C Program to count vowels, digits, spaces, consonants using the string concepts
- Count and display vowels in a string in Python
- Java Program to Count the Number of Vowels and Consonants in a Sentence

Advertisements