This is my code and every time I call the insert function I am getting an ouput of: <__main__.CircularList object at 0x10597fd68>
.
I am trying to use the insert function to actually create the circular linked list by calling it with a for loop.
class Link (object):
def __init__ (self, data, next = None):
self.data = data
self.next = next
class CircularList(object):
def __init__(self):
self.first = None
# Insert an element in the list
def insert ( self, item ):
newLink = Link (item)
current = self.first
if (current == None):
self.first = newLink
return
while (current.next != None):
current = current.next
current.next = newLink
newLink.next = self.first