Skip to content
Advertisement

Python Function is returning none although there is the original Value instead of copy

I have a code where I zero a column or row if it contains zero , I have my own function but when I use it it returns None , I made a copy of my matrix and performed changes on it and then I converted the values to the original one and yet I still get no return . my function shouldn’t return values only update the matrix values. here’s the code:

JavaScript

Advertisement

Answer

ConvertMatrix(numOfRows, M) does not return anything which means it implicitly returns None. Hence

JavaScript

turns M into None. There are two changes you should apply in order to make this mutation function approach work:

Change the last line in the function to:

JavaScript

Do not assign the function result:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement