## Monday, October 26, 2020

Solution Exercise 70: python algorithm to extract the list of all words whose len is less than or equal to a given integer #### Exercise 70

Write a python program which extract from a given string s , the list of all words whose len is less than or equal to 4. Example if s = "The Python programming language is open source and very easy to learn" , the program must returns the list
``L = ['The', 'is', 'open', 'and', 'very', 'easy', 'to']``

#### Solution

``````def listWords(s):

# initializing the list we want to get
list_word = []
# converting s into a list
L = s.split()
for word in L:
if (len(word) <= 4):
list_word.append(word)
return list_word

# Example
s = "The Python programming language is open source and very easy to learn"
print(listWords(s)) # display: ['The', 'is', 'open', 'and', 'very', 'easy', 'to']``````

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 