Answer to Question #253578 in Python for mounika

Question #253578

In the given prefix and suffix program, how to print no overlapping statement


1
Expert's answer
2021-10-19T16:17:29-0400
N1 = input("Enter the first string:")
N2 = input("Enter the second string: ")


def overlapping(X1, X2):
    output = ""
    len1, len2 = len(X1), len(X2)
    for i in range(len1):
        match = ""
        for n in range(len2):
            if (i + n < len1 and X1[i + n] == X2[n]):
                match += X2[n]
            else:
                if (len(match) > len(output)): output = match
                match = ""
    if output == '':
        return 'No overlapping'
    else:
        return output


print(overlapping(N1, N2))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS