So I’m getting this error on a line where I have a recursive call. The line where the error occurred looks something like: return some_func(x) - .2
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
I tried return some_func(x) - .2 and x not None and float(x) is True, and other tricks but unsuccessfully so far.
Thanks!
some_func(x)returnsNone, and you cannot subtract a float fromNone—that wouldn’t make any sense. Depending on your needs, you can either make suresome_func(x)never returnsNone(by changing the implementation ofsome_func), or do this:The last two lines can be omitted, since functions in Python implicitly return
None.