#read string input
str1 = input("please enter a string in lower case:")
#create a list of vowels
vowel = ['a','e','i','o','u']
#iterate over the string to find the position of each vowel
for ch in vowel:
#print the vowel
print(ch,end=" ")
for j,y in enumerate(str1):
if ch==y:
#print the index of vowel
print (j,end=" ")
print ()
Step-by-step explanation:
Read a string input and assign it to "str1" variable. Create a "vowel" list
and initialize it with all vowels. iterate over the string, for each vowel
it will print all the index at which this vowel present in the string. Similarly
repeat this for the next vowel and print their index.
Output:
please enter a string in lower case: ahcvasvcsakhvcsavuieoit
a - 0 4 9 15
e - 19
i - 18 21
o - 20
u - 17