ADVERTISEMENT
ADVERTISEMENT

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.
Submitted by Shivang Yadav, on April 15, 2021

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.

Accepting strings containing all vowels in Python

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.

Example:

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

Input:
"IamReadingourBook"
Output:
Yes

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

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".

Program to accept a string containing 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:

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

Python String Programs »



ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.