title: binary tree, represented by nested parentheses
body: <p>I'm new to python, I'm building a tree, this is my code:</p>
  <pre><code>class BinaryTree():
      def __init__(self, dado, left = None, right = None):
          self.dado = dado
          self.left = left
          self.right = right
  </code></pre>
  <p>I want to make a function to represent the binary tree,
  represented by nested parentheses. This function receives the root and shows, in one line, the structure of the elements.
  For example, the tree:</p>
  <p><a href="https://i.stack.imgur.com/8k7cl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8k7cl.png" alt="enter image description here" /></a></p>
  <p>is displayed as <code>(1 (2 () ()) (3 () (4 () ())))</code>.</p>
  <p>In this tree, the root of the tree is represented by the outermost parentheses, followed by the parentheses that encompass the left child <code>(2 () ())</code> of the root, and then the parentheses that encompass the right child <code>(3 () ( 4 () ) ( )))</code> from the root. The left node has no children <code>()()</code> while the right node has a child <code>(4()())</code>, and this is also a leaf <code>()()</code>.</p>
  <p>I tried to create the function but I couldn't leave it with the expected output... the result of my function comes out like this:</p>
  <pre><code>1
  2
  3
  4
  </code></pre>
  <p>my code, trying to create a function, was this:</p>
  <pre><code>def show(node):
      string = []                                       
      if not node: 
          return      
      print(node.dado)
      show(node.left) 
      show(node.right)  
  </code></pre>