TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'如何处理?

关于“+”,如何处理'NoneType' and 'float'

def minPathCost_Memo(cost, i, j, memo):
    # 请在下面编写代码
    if not (memo[i][j]==0):
        return memo[i][j]
    if (i==0) and (j==0):
        memo[i][j]=cost[0][0]
    elif i==0 and j>0:
        memo[i][j]=minPathCost_Memo(cost,i,j-1,memo)+float(cost[0][j])
    elif j==0 and i>0:
        memo[i][j]=minPathCost_Memo(cost,i-1,j,memo)+float(cost[i][0])
    elif j>0 and i>0:
        x=minPathCost_Memo(cost,i-1,j,memo)
        y=minPathCost_Memo(cost,i,j-1,memo)
        memo[i][j]=min(x,y)+float(cost[i][j])
        return memo[i][j]
    # 请不要修改下面的代码
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

确保你的这个函数minPathCost_Memo必然返回值,你的定义里面仅最后一种情况返回值,其他的elif根本没有返回值