## Wednesday, November 11, 2020

Solution Exercise 87: python algorithm which determines the list of common characters to two strings #### Exercie 87

Write a Python algorithm as a function which takes as parameter a tuple of two strings (s1, s2) and which returns the list of common characters to s1 and s2.
Example: if s1 = 'Python language' and s2 = 'Java Programming', the function returns:
``['P', 'o', 'n', ' ', 'a', 'g']``

#### Solution

``````def commonCharacters(s1 , s2):
listCommon = []
for x in s1:
if x in s2 and x not in listCommon:
listCommon.append(x)
return listCommon

s1 = "Python language"
s2 = "Java Programming"
print(commonCharacters(s1 , s2)) # the output is: ['P', 'o', 'n', ' ', 'a', 'g']``````

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 