## Sunday, October 25, 2020

Solution Exercise 62: python algorithm which determines the list of digit within a given string #### Exercise 62

Write a Python program that determines the list of digits within a given string. Example if s = "Python3.8 is more powerful than Python2.7 " the program must returns the list :
``['3', '8', '2', '7']``

#### Solution

``````def digit(s):
# initializing the list of digits within the string s.
digitList = []

# iterate over all characters of s:
for x in s:
if x.isdigit():
digitList.append(x)

return  digitList

#Testing algorithm:
s = "Python3.8 is more powerful than Python2.7 "
print("List of digits within the string s :" , digit(s))
# The output is :
# List of digits within the string s : ['3', '8', '2', '7']``````

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 