## Thursday, October 15, 2020

Solution Exercise 46: python algorithm that extract all word of given length #### Exercise 46

Write a Python program as a function which takes as parameter a string s and which returns the list of all the words contained in s whose length is greater than or equal to 8. Example if s = 'Python is oriented programming language. Python is the most used programming language'. The function returns the words list :
``['oriented', 'programming', 'language', 'programming', 'language']``

#### Solution

``````def selectWords(s):
# initialize the list we are looking for
L = []

# getting the list of word contained in s
listWords = s.split()

# select all word of length >= 8
for word in listWords:
if len(word) >=8:
L.append(word)
return L

# testing algorithm
s = 'Python is oriented programming language and the most used programming language '

print('List of all word whose lenght is >= 8 is list_word = ' , selectWords(s))
# The output is :
# List of all word whose lenght is >= 8 is list_word =  ['oriented', 'programming', 'language', 'programming', 'language']``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 