## Sunday, October 18, 2020

Solution Exercise 50: python function that extract all numerical character from given string #### Exercise 50

Write a python program as a function which takes a string s as a parameter and returns the list of numeric characters contained in the string s. Example if s = 'Python 3.0, released in 2008, and completely revised in 2020' the function returns the list: [3, 0, 2, 0, 0, 8, 2, 0, 2, 0].

#### Solution

``````def extractNumbers(s):
# initializing extracted list numbers
L = []

for x in s:
if x.isnumeric():
x = int(x)
L.append(x)
return L
s = 'Python 3.0, released in 2008, and completely revised in 2020'
print(extractNumbers(s))
# The output is : [3, 0, 2, 0, 0, 8, 2, 0, 2, 0]``````

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 