Finding common characters in two strings

前端 未结 13 2594
终归单人心
终归单人心 2020-12-15 14:09

I am coding for the problem in which we got to count the number of common characters in two strings. Main part of the count goes like this

for(i=0; i < st         


        
13条回答
  •  情书的邮戳
    2020-12-15 14:26

    Python Code:

        >>>s1='abbc'    
        >>>s2='abde'
        >>>p=list(set(s1).intersection(set(s2)))
        >>print(p)
        ['a','b']
    

    Hope this helps you, Happy Coding!

提交回复
热议问题