Blog Archive

search

Wednesday, August 7, 2019

Python program to find the longest common sub-string from two given strings

from difflib import SequenceMatcher

a=input('enter first string : ')
b=input('enter second string : ')

c = SequenceMatcher(None,a,b)
match = c.find_longest_match(0, len(a), 0, len(b))
if (match.size!=0):
    print(a[match.a: match.a + match.size]) 
else:
    print('Longest common sub-string not present') 

No comments:

Post a Comment

Python program to create a string from two given strings concatenating uncommon characters of the said strings

PROGRAM :  a = input('Enter a string : ') b = input('Enter a string : ') c='' for i in a:     if(i not in b):...