Write A Python Program To List All The Words Starting With Vowels In A Given Input Paragraph

Given a paragraph as a user input to the Python program,  you have to write a Python logic where you have to print all the words in the paragraph that start with vowels.

Let's use the Python for loop to iterate all the words and print the words that  start with vowels.

 

 

Write A Python Program To List All The Words Starting With Vowels In A Given Input Paragraph



Write A Python Program To List All The Words Starting With Vowels In A Given Input Paragraph

 let's take a Python variable named as text and using the input function call ask a user to enter a paragraph.  take another variable named vowels and declare the vowel string that is "aeiouAEIOU"  containing a string of vowels in uppercase and lowercase inside the program.

text = input("Enter a Paragraph : ")
vowels = "aeiouAEIOU"



 using the print statement just print a user-friendly message that is word starting with vowels are and then let's use the for loop to print the words starting with vowels. Take a for loop and try to split the paragraph using the space and take individual words present in the paragraph.  check if the first character of the word is a vowel using the if statement and use the print statement to print each and every word that starts with the vowels.

print("Words starting with Vowels are ...")
for word in text.split(" "):
    if word[0] in vowels:
        print(word, end=" ")



Code
=============================
text = input("Enter a Paragraph : ")
vowels = "aeiouAEIOU"

print("Words starting with Vowels are ...")
for word in text.split(" "):
    if word[0] in vowels:
        print(word, end=" ")





OUTPUT
=================
Enter a Paragraph : python program to print vowels in paragraph
Words starting with Vowels are ...
in



OUTPUT
==============
Enter a Paragraph : how are you ? let's got to movie
Words starting with Vowels are ...
are



OUTPUT
===============
Enter a Paragraph : biggest city in the world
Words starting with Vowels are ...
in



Conclusion
=================
Execute the above  Python program by providing the random string as an input to the program.  note down the results.


Comment down below if you have any other  method to solve this Python program.





Post a Comment

0 Comments