Hi all, I am struggling to understand following example code at p.198 EPI Python:
def search_bst(tree, key): # whether the key present in the tree
if not tree or tree.data == key else search_bst(tree.left, key)
if key < tree.data else search_bst(tree.right, key)
I know A if condition else B gives A when the condition met, else we get B.
However, above code is hard to get because (1) it has two if s (2) the “if not tree or tree.data == key” part seems convoluted (at least for me). How can I decode this? Could anyone explain the meaning of this?