my_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
Create a binary tree from the list
def binary_tree(list): if len(list) == 0: return None mid = len(list)//2 root = list[mid] tree = {root: {'left': binary_tree(list[:mid]), 'right': binary_tree(list[mid+1:])}} return tree