
- 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 accept the strings which contains all vowels
Sometimes you want to accept input based on certain conditions. Here, we are going to see the same type of program. We will write a program that allows only words with vowels. We will show them whether the input is valid or not.
Let's see the approach step by step.
Define a list of vowels [A, E, I, O, U, a, e, i, o, u]
Initialize a word or sentence.
Iterate over the word or sentence.
Check if it is present in the list or not.
3.1.1. If not, break the loop and print Not accepted.
- Else print accepted
Example
Let's convert the text into Python code.
def check_vowels(string): # vowels vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'] # iterating over the string for char in string: if char not in vowels: print(f"{string}: Not accepted") break else: print(f"{string}: Accepted") if __name__ == '__main__': # initializing strings string_1 = "tutorialspoint" string_2 = "AEiouaieeu" # checking the strings check_vowels(string_1) check_vowels(string_2)
Output
If you run the above code, you will get the following results.
tutorialspoint: Not accepted AEiouaieeu: Accepted
Conclusion
You check different properties based on your requirements. If you have any doubts in the tutorial, mention them in the comment section.
- Related Articles
- Java program to accept the strings which contain all vowels
- C# program to check for a string that contains all vowels
- Python Program to Accept Three Digits and Print all Possible Combinations from the Digits
- Program to find longest substring of all vowels in order in Python
- Python Program to accept string starting with vowel
- Java Program to count all vowels in a string
- Python Program – Strings with all given List characters
- Program to sort all vowels at beginning then the consonants, are in sorted order in Python
- Program to generate all possible strings by taking the choices in python
- JavaScript Return an array that contains all the strings appearing in all the subarrays
- Python Program to accept string ending with alphanumeric character
- Python program to check if a string contains all unique characters
- Program to find total number of strings, that contains one unique characters in Python
- Python program – All occurrences of Substring from the list of strings
- Find substrings that contain all vowels in Python

Advertisements