human
Minimum number of deletions and insertions to transform one string into another | Returns length of length common subsequence for str1 [ 0. . m - 1 ] , str2 [ 0. . n - 1 ].
Following steps build L [ m + 1 ] [ n + 1 ] in bottom up fashion . Note that L [ i ] [ j ] contains length of LCS of str1 [ 0. . i - 1 ] and str2 [ 0. . j - 1 ].
L [ m ] [ n ] contains length of LCS for X [ 0. . n - 1 ] and Y [ 0. . m - 1 ].
function to find minimum number of deletions and insertions.
Driver Code.
Function Call"
How can the above be solved in Python?

Can you provide a code to minimum number of deletions and insertions to transform one string into another and the other steps required?
assistant
#Here is code to minimum number of deletions and insertions to transform one string into another and the other steps required.
 def lcs ( str1 , str2 , m , n ) :
	L = [ [ 0 for i in range ( n + 1 ) ] for i in range ( m + 1 ) ]
	for i in range ( m + 1 ) :
		for j in range ( n + 1 ) :
			if ( i == 0 or j == 0 ) :
				L [ i ] [ j ] = 0
			elif ( str1 [ i - 1 ] == str2 [ j - 1 ] ) :
				L [ i ] [ j ] = L [ i - 1 ] [ j - 1 ] + 1
			else :
				L [ i ] [ j ] = max ( L [ i - 1 ] [ j ] , L [ i ] [ j - 1 ] )
	return L [ m ] [ n ]
def printMinDelAndInsert ( str1 , str2 ) :
	m = len ( str1 )
	n = len ( str2 )
	leng = lcs ( str1 , str2 , m , n )
	print ( " Minimum ▁ number ▁ of ▁ deletions ▁ = ▁ " , m - leng , sep = ' ▁ ' )
	print ( " Minimum ▁ number ▁ of ▁ insertions ▁ = ▁ " , n - leng , sep = ' ▁ ' )
str1 = " heap "
str2 = " pea "
printMinDelAndInsert ( str1 , str2 )