I
I
igoodmood2016-03-27 15:07:45
Python
igoodmood, 2016-03-27 15:07:45

How to properly organize the work of the insert function?

When testing, the following error occurs:
8d88bd45d16049d59436a5f154a46cec.PNG

def insert(self,item,pos):
        current = self.head
        found = False
        count = 0
        while not found:
            if count == pos-2:
                found = True
            else :
                current = current.getNext()
                count = count + 1
        temp = Node(item)
        temp.setNext(current.getNext())
        current.setNext(temp)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question