Accept a string containing vowels only.

In this program, we will accept a string containing vowels only. If it has any consonants do not accept it.

Steps to solve the program
  1. Take a string as input.
  2. Check whether the string contains any consonants.
  3. If yes then, print Not Accepted else print Accepted.
  4. Use for loop for this purpose.
				
					#Input string
str1 = "python"
count = 0
List = ["a","e","i","o","u","A",
       "E","I","o","U"]

for char in str1:
    if char in List:
        count += 1

if count == len(str1):
    print("Accepted")
else:
    print("Not Accepted")
    
    
str2 = "aaieou"
count = 0
List = ["a","e","i","o","u","A",
       "E","I","o","U"]

for char in str2:
    if char in List:
        count += 1

if count == len(str2):
    print("Accepted")
else:
    print("Not Accepted")
				
			

Output :

				
					Not Accepted

Accepted
				
			

avoid spaces in string and get the total length

remove the kth element from the string

Leave a Comment