When recursion is used and there is a return value, the return statement needs to be added when calling its own function as follows:
def daxiao (Biao1,biao2): #判断两个列表的大小, returns 1, # based on the element size #如果biao1大于biao2 If BIAO1 is less than Biao2, return 0 #如果两者相等, return 3 Geshu1=len (biao1) Geshu2=len (BIAO2) B1=int (biao1[0]) B2=int (biao2[0]) #这里只能比较数值大小, cannot directly compare size by string print (biao1 ) Print (BIAO2) print (B1,B2, ' d ') if B1>B2: print (b1,b 2) return 1 elif b1<b2: return 0 else: if (geshu1==geshu2==1): print (' same name ') return 3 elif (Geshu1==1 and geshu2>1): &nbs P return 0 elif (geshu1>1 and Geshu2==1): &NBSP ; return 1 ELSE:&Nbsp; # A=daxiao (biao1[-geshu1+1:],biao2[1-geshu2:]) & nbsp # return a #上面两句和这一句是等价的
returnDaxiao (BIAO1[-GESHU1+1:],BIAO2[1-GESHU2:])Return must be added here, otherwise the returned value is None,
Because when the function is called, the data is transmitted inward, and when no return is added, the data cannot be transferred back. The return in the method only jumps out of the layer function that is called, and when it is transferred to the outermost level, the statement is in the function that is called, and runs without return returns none. so you have to add a return after calling the function. Either add two words like green, or just return as red.
Https://www.cnblogs.com/yechenkai/p/7143475.html
Python recursive call return value problem