#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-

# Source: https://youtu.be/6oL-0TdVy28


class Node(object):
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None


class BinaryTree(object):
    def __init__(self, root):
        self.root = Node(root)

    def print_tree(self, traversal_type):
        if traversal_type == 'preorder':
            return self.preorder_print(self.root, '')
        else:
            print('Traversal type ' + str(traversal_type) + ' is not supported')
            return False

    def preorder_print(self, start, traversal):
        """ Root -> Left -> Right """
        if start:
            traversal += (str(start.value) + '-')
            traversal = self.preorder_print(start.left, traversal)
            traversal = self.preorder_print(start.right, traversal)
        return traversal

# Tree representation:
#          1
#        /   \
#       2     3
#      / \   / \
#     4   5 6   7


# Tree setup:
binary_tree = BinaryTree(1)
binary_tree.left = Node(2)
binary_tree.right = Node(3)
binary_tree.left.left = Node(4)
binary_tree.left.right = Node(5)
binary_tree.right.left = Node(6)
binary_tree.right.right = Node(7)

print(binary_tree.print_tree('preorder'))

@@ -374,25 +374,25 @@
 type == 
-'
+%22
 preorder
 ':%0A     
@@ -383,17 +383,17 @@
 preorder
-'
+%22
 :%0A      
@@ -429,21 +429,116 @@
 int(
-self
+tree.root, %22%22)%0A        elif traversal_type == %22inorder%22:%0A            return self.inorder_print(tree
 .root, 
-''
+%22%22
 )%0A  
@@ -549,117 +549,431 @@
   el
-se:%0A            print('Traversal type ' + str(traversal_type) + ' is not supported')%0A            return False
+if traversal_type == %22postorder%22:%0A            return self.postorder_print(tree.root, %22%22)%0A%0A    def preorder_print(self, start, traversal):%0A        %22%22%22 Preorder traversal. Root -%3E Left -%3E Right %22%22%22%0A        if start:%0A            traversal += (str(start.value) + '-')%0A            traversal = self.preorder_print(start.left, traversal)%0A            traversal = self.preorder_print(start.right, traversal)%0A        return traversal
 %0A%0A  
@@ -970,35 +970,34 @@
 versal%0A%0A    def 
-pre
+in
 order_print(self
@@ -1029,31 +1029,43 @@
     %22%22%22 
-Root -%3E
+In-order traversal.
  Left -%3E
  Right %22
@@ -1048,32 +1048,39 @@
 aversal. Left -%3E
+ Root -
  Right %22%22%22%0A     
@@ -1118,35 +1118,321 @@
 sal 
-+= (str(start.value) + '-')
+= self.inorder_print(start.left, traversal)%0A            traversal += (str(start.value) + '-')%0A            traversal = self.inorder_print(start.right, traversal)%0A        return traversal%0A%0A    def postorder_print(self, start, traversal):%0A        %22%22%22 Post-order traversal. Left -%3E Right -%3E Root %22%22%22%0A        if start:
 %0A   
@@ -1555,32 +1555,82 @@
 ght, traversal)%0A
+            traversal += (str(start.value) + '-')%0A
         return t
@@ -1660,17 +1660,17 @@
 entation
-:
+.
 %0A#      
@@ -1745,31 +1745,124 @@
   7%0A
-%0A%0A# Tree setup:%0Abinary_
+# Pre-order:    1-2-4-5-3-6-7-%0A# In-order:     4-2-5-1-6-3-7-%0A# Post-order:   2-4-5-3-6-7-1-%0A%0A%0A# Binary tree setup.%0A
 tree
@@ -1878,27 +1878,25 @@
 Tree(1)%0A
-binary_tree
+tree.root
 .left = 
@@ -1903,27 +1903,25 @@
 Node(2)%0A
-binary_tree
+tree.root
 .right =
@@ -1929,27 +1929,25 @@
 Node(3)%0A
-binary_tree
+tree.root
 .left.le
@@ -1959,27 +1959,25 @@
 Node(4)%0A
-binary_tree
+tree.root
 .left.ri
@@ -1990,28 +1990,26 @@
 Node(5)%0A
-binary_
 tree.
+root.
 right.le
@@ -2021,28 +2021,26 @@
 Node(6)%0A
-binary_
 tree.
+root.
 right.ri
@@ -2064,15 +2064,8 @@
 int(
-binary_
 tree
@@ -2080,16 +2080,86 @@
 ree('pre
+order'))%0Aprint(tree.print_tree('inorder'))%0Aprint(tree.print_tree('post
 order'))

Update binary_tree.py