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
- Take a string as input.
- Check whether the string contains any consonants.
- If yes then, print Not Accepted else print Accepted.
- 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