Python program to accept the strings which contains all vowels

Here, we will take a string as input from the user and then accept all the strings containing all vowels using Python. By Shivang Yadav Last updated : March 01, 2024

Python programming language is a high-level and object-oriented programming language. Python is an easy to learn, powerful high-level programming language. It has a simple but effective approach to object-oriented programming.

Strings in Python are immutable means they cannot be changed once defined.

Problem statement

We will take a string as input from the user and then return YES or NO based on the presence of all vowels in the string.

We will accept only those strings which have all vowels present in them.

Example

Consider the below example with sample input and output:

Input:
"inlcudehelp"
Output:
No
Explanation:
The string does not contain 'a' and 'o' vowels. 

Input:
"IamReadingourBook"
Output:
Yes

Accepting strings containing all vowels in Python

To check if the string contains all vowels, we will create a set of vowels and then if any character from the array is a vowel. We will delete it from the vowel set. At the end, if the vowel set's length is 0, then print "YES" otherwise "No".

Python program to accept the strings which contains all vowels

# Python program to check if the string 
# contains all vowels or not

# Getting string input from the user 
myStr =  input('Enter the string : ')

# Checking if the string contains all vowels or not
myStr = myStr.lower()
allVowels = set("aeiou")

for char in myStr :
    if char in allVowels :
        allVowels.remove(char)

print("Entered String is ", myStr)
if len(allVowels) == 0:
    print("The string contains all vowels")
else :
    print("The string does not contain all vowels")

Output

The output of the above program is:

RUN 1:
Enter the string : IncludeHelp
Entered String is  includehelp
The string does not contain all vowels

RUN 2:
Enter the string : I am reading our book
Entered String is  i am reading our book
The string contains all vowels

To understand the above program, you should have the basic knowledge of the following Python topics:

Python String Programs »

Related Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.