Saturday, 15 April 2017

Insert specific Node in index Linked List on Python

i have sort of problem imagining or solving this, i have this node and list

class node:
    def __init__(self, info):
        self.info = info
        self.next = None

class list:
    def __init__(self):
        self.__first = None
        self.__last = None

and i have to create a function, called indexL(self, info, position), that put the exact node in the desired position, here is what i have for now (i have created already a method called self.length() to give the size of the list)

def indexL(self, info, position):
    longit = self.length()
    n = node(info)
    p = self.__first
    if index == 0:
        self.__first = n
    else:
        if index > 0 and index < longit:
           if index == tam-1:
                self.__last = n
            else:

and now i'm stuck there, if someone want to help or any recommendation, i would be really grateful



via Esteban

No comments:

Post a Comment