Program
#Method to find common string
#Pass two strings as arguments
#Print commonstring if present
#Otherwise NONE
def CommonDifference(A,B):
#Check empty string
if len(A)==0 or len(B)==0:
print("NONE")
#Otherwise
else:
#Generate lists of the
strings
lstA=A.split()
lstB=B.split()
#List for comparison
storage
firstComp=[]
secondComp=[]
commStr=[]
#Loop to find A to B
comaprarison
for i in
range(0,len(lstA)):
index=B.find(lstA[i])
if(index>=0):
firstComp.append(lstA[i])
firstComp.append(" ")
#Loop to find B to A
comaprarison
for i in
range(0,len(lstB)):
index=A.find(lstB[i])
if(index>=0):
secondComp.append(lstB[i])
secondComp.append(" ")
#Generate strings
firstComp="".join(firstComp)
secondComp="".join(secondComp)
#Second algorithm loop
for i in range(0,len(firstComp)):
#Find index of character
match
index=secondComp.find(firstComp[i])
#Check the found index
not space
if(index>=0 and
firstComp[i]!=' '):
#Add into comparison list
commStr.append(firstComp[i])
#Remove charcters including inex
secondComp=secondComp[index+1:]
#Generate common string
commStr="".join(commStr)
#Check empty or not
#Then print corresponding result
if(len(commStr)>0):
print(commStr)
else:
print("NONE")
#Main
def main():
#Check
CommonDifference("The quick brown fox did jump
over a log","The brown rabbit quickly did outjump the fox")
#Call main
main()
---------------------------------------------------------
Output
Theiox
----------------------------------------------
MAKE SURE OUTPUT 4 IS CORRECT - Python PROBLEM: A useful computer utility is to report...
Recursion and Trees Application – Building a Word Index Make sure you have read and understood · lesson modules week 10 and 11 · chapters 9 and 10 of our text · module - Lab Homework Requirements before submitting this assignment. Hand in only one program, please. Background: In many applications, the composition of a collection of data items changes over time. Not only are new data items added and existing ones removed, but data items may be duplicated. A list data structure...