inp = open('input.txt', 'r') # working with file
out = open('output.txt', 'a')
class Node: # class to building tree
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def insert(self, data):
if self.data is None:
self.data = data
else:
if data < self.data:
if self.left is None:
self.left = Node(data)
else:
self.left.insert(data)
elif data > self.data:
if self.right is None:
self.right = Node(data)
else:
self.right.insert(data)
n = Node()
data = inp.read()
n.insert(data)
out.write(str(data))
inp.close()
out.close()
Parameter 'data' unfilled Shadows name 'data' from outer scope
I don't understand how to fix it. It would be grateful if you could help me with my problem.