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


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")
      print(f"{string}: Accepted")
if __name__ == '__main__':
   # initializing strings
   string_1 = "tutorialspoint"
   string_2 = "AEiouaieeu"
   # checking the strings


If you run the above code, you will get the following results.

tutorialspoint: Not accepted
AEiouaieeu: Accepted


You check different properties based on your requirements. If you have any doubts in the tutorial, mention them in the comment section.