I need to make a linked list and the constructor has these requirements:
- init(self, head) • The constructor. We’ll have 3 attributes: head, tail, and count. • Make it so we can pass a reference to a node to create an OurLinkedList. • This means that we can by default create an empty list (nothing is passed to the constructor), OR start with an arbitrarily large linked structure (a reference to a node is passed to the constructor).
im having trouble understanding how and when to make objects in my code this is what i have so far:
def __init__(self, head):
self.head= head
a= OurLinkedList(self.head)
curNode= self.head
self.count= 0
while curNode is not None:
self.count += 1
curNode= curNode.next
self.tail= curNode
and I get RecursionError: maximum recursion depth exceeded while calling a Python object