In this program, we will take a user input as a string and convert it into a list. To check for words that have vowels in string with the help of the below-given steps.
Words which has vowels in string:
Steps to solve the program
- Take a string as input.
- Split the given string using split() and create an empty list.
- Using for loop and if statement check whether a word in the splitter string contains any vowels.
- If it has any vowels then add that word to the empty list.
- Print the list to see the words which has vowels in string.
#Input string
string = "www Student ppp are qqqq learning Python vvv"
#Splitting a atring
string2 = string.split()
#Creating an empty list
list1 = []
for words in string2:
for char in words:
#Checking for vowels
if char == "a" or char == "e" or char == "i"
or char == "o" or char == "u":
list1.append(words)
break
#Printing output
print(list1)
Output :
['Student', 'are', 'learning', 'Python']
Related Articles
Python program to add 2 lists with extend method.
Python program to sort list data, with the sort and sorted method.
Python program to remove data from the list from a specific index using the pop method.
Python program to get the max, min, and sum of the list using in-built functions.
Python program to check whether a list contains a sublist.
Python program to generate all sublists with 5 or more elements in it from the given list.