from copy import deepcopy
tree={'A':['B','C'],
'B':['D','E'],
'C':['F','G']}
treedict=deepcopy(tree)
i need help here .i have a tree which is a dict containing lists.i wonder how i can insert a node in the top of the tree and at the bottoom here is what i tried
def InsertNodeInTreeBottom(newnode,nodeparent,treedict):
for k in treedict.iteritems():
if (k==nodeparent):
node=nodeparent
children=treedict[node]
children.append[newnode
return treedict
but there is no change in the tree even after i try to add.
for example i would like InsertNodeInTreeBottom('X','F',treedict) ,the tree must look like
tree={'A':['B','C'],
'B':['D','E'],
'C':['F','G']
'F':['x']}