Exercise 63

Write a program in python allowing to extract from a list of strings, the list of strings containing at least two vowels. Example if

L = ["Java", "Python", "Dart", "MySql"]

, the program returns the list

["Java", "Python"]



#coding: utf-8
def vowel (L):
# initialization of the list of words containing at least two vowels
lVowels = []
#define vowels list
vowelist = ['a', 'e', 'y', 'u', 'i', 'o']

for u in L:
# initialize the number of vowels contained in u
numberVowels = 0
for x in u:
if x in vowelist:
numberVowels = numberVowels + 1
if numberVowels >= 2:
lVowels.append (u)
return lVowels

# Example
L = ["Java", "Python", "Dart", "MySql"]
print (vowel (L)) # the output is: ['Java', 'Python']
# The output is: ['Java', 'Python']

Younes Derfoufi

Leave a Reply