human
Print the longest common substring | function to find and print the longest common substring of X [ 0. . m - 1 ] and Y [ 0. . n - 1 ].
Create a table to store lengths of longest common suffixes of substrings . Note that LCSuff [ i ] [ j ] contains length of longest common suffix of X [ 0. . i - 1 ] and Y [ 0. . j - 1 ] . The first row and first column entries have no logical meaning , they are used only for simplicity of program.
To store length of the longest common substring.
To store the index of the cell which contains the maximum value . This cell 's index helps in building  up the longest common substring  from right to left..
Following steps build LCSuff [ m + 1 ] [ n + 1 ] in bottom up fashion ..
if true , then no common substring exists.
allocate space for the longest common substring.
traverse up diagonally form the ( row , col ) cell until LCSuff [ row ] [ col ] != 0.
move diagonally up to previous cell.
required longest common substring.
Driver Code"
How can the above be solved in Python?
 ... Write me a code to print the longest common substring and the other steps required?
assistant
#Here is code to print the longest common substring and the other steps required.
 def printLCSSubStr ( X : str , Y : str , m : int , n : int ) :
	LCSuff = [ [ 0 for i in range ( n + 1 ) ] for j in range ( m + 1 ) ]
	length = 0
	row , col = 0 , 0
	for i in range ( m + 1 ) :
		for j in range ( n + 1 ) :
			if i == 0 or j == 0 :
				LCSuff [ i ] [ j ] = 0
			elif X [ i - 1 ] == Y [ j - 1 ] :
				LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1
				if length < LCSuff [ i ] [ j ] :
					length = LCSuff [ i ] [ j ]
					row = i
					col = j
			else :
				LCSuff [ i ] [ j ] = 0
	if length == 0 :
		print ( " No ▁ Common ▁ Substring " )
		return
	resultStr = [ '0' ] * length
	while LCSuff [ row ] [ col ] != 0 :
		length -= 1
		row -= 1
		col -= 1
	print ( ' ' . join ( resultStr ) )
if __name__ == " _ _ main _ _ " :
	X = " OldSite : GeeksforGeeks . org "
	Y = " NewSite : GeeksQuiz . com "
	m = len ( X )
	n = len ( Y )
	printLCSSubStr ( X , Y , m , n )