def minedit(str1,str2): m=len(str1) n=len(str2) # max_num=9999 dp=[[None for i in range(n+1)]for j in range(m+1)] dp[0][0]=0 for i in range(m): dp[i][0]=0 for i in range(1,m+1): for j in range(1,n+1): if str1[i-1]==str2[j-1]: dp[i][j]=dp[i-1][j-1] else: ## if dp[i-1][j]!=None: dp[i][j]=dp[i-1][j]+1 result=None for i in range(n,m+1): if result==None: result=dp[i][n] else: result=min(result,dp[i][n]) return result