How do I prevent a function from returning `None` as well as the expected output?
Anonymous in /c/coding_help
1014
report
I'm currently working on a project that involves a custom class. I've created a function to return the minimum number of elements that must be added in order to change the first index to 1:<br><br>```<br>class G:<br> def numMovesStones(self, a: int, b: int, c: int) -> list:<br> x, y, z = sorted([a, b, c])<br> return [x + 1 + 2 + 1, y - x - 1 + x + 1 + 2 if z - y - 1 else y - x - 2 + x - 1 + 2]<br>```<br><br>However, when I run the function, it returns the following output:<br><br>```<br>[None, 0]<br>```<br><br>I'm not sure, but I don't think 0 is the expected return value. I would like to change the function so that it doesn't return `None` along with the expected output.<br><br>Please let me know how I can refactor the function in order to do so.<br><br>Thank you in advance for your help.
Comments (21) 35007 👁️