python - Finding common characters -


q: best approach tackling problem?

for example, if 2 values "chocolate" , "cockroach" function should return "choa"

research:

i have found find(),or making list witch helpful structuring function.

code: having issues!

value1 = input("please input word: ") value2 = input("please input second word: ") [how find similar letters in 2 words] print(similar_letters) 

example:

 please input word: hello  please input second word: hey letters in word : 'he' 

perhaps meant common characters? use sets, long don't mind remove duplicates , change order of elements:

s1 = set("chocolate") s2 = set("cockroach")  "".join(s1 & s2) => "ahco" 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -