I’m writing a tree traversal method. The output needs to be on one line. When the method is complete, though, I’d like to insert a line break. Is there any way to do this within the function, or will it have to be called from outside?
Right now I have:
def postorder_transversal(self):
if self.node == None:
return 0
for child in self.children:
child.postorder_transversal()
print self.node,
Any thoughts on how to alter it?
You could do it inside the function like so:
though it may be cleaner to just do it outside.