class List():
def __init__(self,values=0):
self.numb=values
self.linker=self
def add(self,values):
self=self.linker
self.numb=values
self.linker=List()
def show(self):
while self!=self.linker:
print self.numb
self=self.linker
In main call i want some thing like this
list1=List()
list1.add(43) #i want to add numbers to liked list node like this
list1.add(22)
list1.add(938)
list1.show()#Then retrieve it from the linked list(list1)
I am not sure about the logic because when i want to add third number it just saves it to the 2nd node of the linked list ,so more precisly its storing first list.add(43) and list.add(938) where is list1.add(22) gone ? ...Please write some code and explain so that i can add more numbers and display them using Obj.add() and Obj.show() Notation ..Thanks in advance