Home / Expert Answers / Computer Science / what-is-causing-the-error-nbsp-and-how-can-i-remove-it-error-cannot-assign-member-34-left-34-for-typ-pa581

(Solved): what is causing the error  and how can I remove it. error:Cannot assign member "left" for type ...



what is causing the error  and how can I remove it.

error:Cannot assign member "left" for type "Node"
  Expression of type "Node" cannot be assigned to member "left" of class "Node"
    Type cannot be assigned to type "None"

 

code:

class Node(object):

    def __init__(self,value):

        self.left = None

        self.right = None

        self.value = value

 

class binary_tree(object):

    def __init__(self,root):

        self.root = Node(root)




 

my_tree = binary_tree(10)

my_tree.root.left = Node(12)

my_tree.root.right = Node(8)



We have an Answer from Expert

View Expert Answer

Expert Answer


This error is occurring because you are trying to assign a value of type Node to the left field of a
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe