When using a conditional return, if you attempt to return more than one value from function, the function behaves erratically with regard to the actual return value.
def test_function(x,y, diagnostic:bool=False): w = x*y z = [] if diagnostic: z = [w,w*2] return z, w if diagnostic else w print(test_function(3,4)) # output tuple ([],12) # lets switch order of the return from z,w to w,z def test_function(x,y, diagnostic:bool=False): w = x*y z = [] if diagnostic: z = [w,w*2] return w,z if diagnostic else w print(test_function(3,4)) # output tuple (12,12) # lets try retun the diagnostic value itself to see what function things is happening def test_function(x,y, diagnostic:bool=False): w = x*y z = [] if diagnostic: z = [w,w*2] return diagnostic if diagnostic else w print(test_function(3,4)) # returns 12, so diagnostic is retuning false # rewrite conditional to "if not" def test_function(x,y, diagnostic:bool=False): w = x*y z = [] if diagnostic: z = [w,w*2] return w if not diagnostic else w,z print(test_function(3,4)) # returns (12, [])