Skip to content

How to find common characters in two strings in Python?

Advertisements
#Finding common elements between two strings
str1 = 'poopcode'
str2 = 'code'
common = ''.join(set(str1).intersection(str2))
print(common)
See also  Java code snippet - How to use old android studio project?
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.