def build_bst(l):
if len(l) == 1:
return l
mid = len(l) // 2
return bst = {'data': l[mid]}, bst["left_child"] == {'data': build_bst(l[:mid])}, bst["right_child"] == {'data': build_bst(l[(mid+1):])}
sorted_list = [12, 13, 14, 15, 16]
binary_search_tree = build_bst(sorted_list)
print(binary_search_tree)
Error:
File "recursion.py", line 6
return bst = {'data': l[mid]}, bst["left_child"] == {'data': build_bst(l[:mid])}, bst["right_child"] ==
{'data': build_bst(l[(mid+1):])}
^
SyntaxError: invalid syntax
Can someone explain what is wrong with my code, I can't seem to find the mistake.