Q. Write a function Push(Vow) to store unique words starting with vowels named Vow from the string inputted by the user.

Example :- The string inputted is --

"Logic to insert element in order to insert an element in an array"


Contents of the Stack Vow:-

insert --> element --> In --> order --> an --> array


Answer :-

def Push ( vow ) :
      words = vow.split()
      Vow = []
      for i in words :
            if i[0] == "a" or i[0] == "e" or i[0] == "i" or i[0] == "o" or i[0] == "u" or i[0] == "A" or i[0] == "E" or i[0] == "I" or i[0] == "O" or i[0] == "U" :
                  Vow += [i]
      return Vow

sen = input ("Enter Sentance :- ")
print( Push(sen) )

Output :- 

Enter Sentance :- Logic to insert element in order to insert an element in an array
['insert', 'element', 'in', 'order', 'insert', 'an', 'element', 'in', 'an', 'array']
>>>

Enter Sentance :- This is a website and its name id Pathwalla
['is', 'a','and', 'its', 'id']
>>>


Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post