class linkedlist:
def __init__(self,value):
self.head={'value':value,'next':None}
self.tail=self.head
self.length=1
def append(self,value):
self.newnode={'value':value,'next':None}
self.tail['next']=self.newnode
self.tail=self.newnode
self.length+=1
if __name__=='__main__':
l=linkedlist(10)
l.append(5)
l.append(16)
The code is working fine but I have doubts about how __init__ works. Will __init__ be called for every function call? Its quite a bit confusing because I am changing the tail and the head value.
How does the main function works here?