How to find the common values that appear in two given strings with Python

1 Answer

0 votes
def intersection_of_two_string(str1, str2):
    result = ""
    for ch in str1:
        if ch in str2 and not ch in result:
            result += ch
    return result

str1 = 'Python3.9.7 Java 8 Update 301'
str2 = 'Python3.8.12 Java 8 Update 8u20'

print(intersection_of_two_string(str1, str2))



 
'''
run:

Python3. Jav8Upde01
 
'''

 



answered Sep 14, 2021 by avibootz
...