Added is_leaf attribute to Leaf and Node class.

parent 3879a9ca
......@@ -5,6 +5,7 @@ class Node(object):
def __init__(self, value, *nodes):
super(Node, self).__init__()
self.value, self.nodes = value, list(nodes)
self.is_leaf = False
def __getitem__(self, n):
return self.nodes[n]
......@@ -37,6 +38,7 @@ class Leaf(Node):
super(Leaf, self).__init__(value)
self.value = value
self.nodes = None
self.is_leaf = True
def __len__(self):
return len(str(self.value))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment