Skip to content

Instantly share code, notes, and snippets.

@thomasballinger
Created April 3, 2014 13:23
Show Gist options
  • Save thomasballinger/9954255 to your computer and use it in GitHub Desktop.
Save thomasballinger/9954255 to your computer and use it in GitHub Desktop.
simple recursive tree display
tree = [1, [2, [10, 3, 4], [11, 5, 6]], [12, 7,8]]
def display(t, indent=0):
if isinstance(t, list):
print ' '*indent, t[0]
display(t[1], indent+4)
display(t[2], indent+4)
else:
print ' '*indent, t
display(tree)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment