CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2021

    Why facing error due to spacing?

    class BinaryTree:
    def __init__(self, root):
    self.key = root
    self.left_child = None
    self.right_child = None

    def insert_left(self, new_node):
    if (self.left_child is None):
    self.left_child = BinaryTree (new_node) # face run-time error here?
    t = BinaryTree(new_node)
    t.left_child = self.left_child
    self.left_child = t
    def insert_right(self, new_node):
    if self.right_child is None:
    self.right_child = BinaryTree(new_node)
    t = BinaryTree(new_node)
    t.right_child = self.right_child
    self.right_child = t
    def get_right_child(self):
    return self.right_child
    def get_left_child(self):
    return self.left_child
    def set_root_val(self, obj):
    self.key = obj
    def get_root_val(self):
    return self.key r

  2. #2
    Join Date
    Sep 2021

    Re: Why facing error due to spacing?

    Have formatted code at:

    The run-time error occurs at line #10.

    It is stated as:

    Traceback (most recent call last):
    File "/usr/lib/python3.7/", line 143, in compile
    File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "./", line 10
    self.left_child = BinaryTree (new_node)
    TabError: inconsistent use of tabs and spaces in indentation

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width