Answer to Question #165333 in Python for hemanth

Question #165333

Prefix Suffix


Write a program to check the overlapping of one string's suffix with the prefix of another string.


Input


The first line of the input will contain a string A.

The second line of the input will contain a string B.


Output


The output should contain overlapping word if present else print "No overlapping".


1
Expert's answer
2021-02-21T19:50:53-0500
# overlapping of a prefix first_str with a suffix second_str
first_str = input('Enter the first string ')
second_str = input('Enter the second string ')
over_lapping =''
# get the length of the smallest word
min_len = min(len(first_str), len(second_str))
for item in range(min_len):
# comparison of a prefix first_str with a suffix second_str
    if first_str[:item + 1] == second_str[-item -1:]:
        over_lapping = first_str[:item + 1]
print(over_lapping) if over_lapping else print('No overlapping')
    

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