## Wednesday, October 28, 2020

Solution Exercise 71: python algorithm which find the minimum digits in given string

#### Exercise 71 **

Write a Python program which determines the minimum digit within a given string s. Example if s = "Python3.7 is more power than Python2.7" , the algorithm must returns 2. We assume that the string s does not contain any negative number.

#### Solution

``````def minimumDigit(s):
# creating and initializing the list of digits
listDigits = []
for x in s:
if x.isdigit():
x = int(x)
listDigits.append(x)

# initializing the minimum of digits
minDigit = listDigits[0]

# iterate over all list elements
for n in listDigits:
if minDigit > n:
minDigit = n
return minDigit
# Example:
s = "Python3.7 is more power than Python2.7"
print("The minimum  digit within s is : ", minimumDigit(s))
# The output is : The minimum  digit within s is :  2``````

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