## Tuesday, October 20, 2020

Solution Exercise 68: python algorithm to find the most amount of shared characters in two strings #### Exercise 68

Write a python algorithm that find the number of common characters in two strings s1 and s2. Example if s = "Hello" and s2 = "World", the shared characters are 'l' and 'o', then the algorithm returns 2.

#### Solution

``````s1 = "Hello"
s2 = "World"

# initializing counter
counter = 0

# creating and initializing a string by deleting the repeated characters in s1
s = ""
for x in s1:
if x not in s:
s = s + x
for x in s:
if x in s2:
counter = counter + 1

# display the number  of common characters in strings s1 and s2
print(counter) # display 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

## Sample Text 