class Node: def __init__(self,data): self.data=data self.next=None class Linkedlist: def __init__(self): self.head=None while(temp): print(temp.data) temp=temp.next def append(self,new_data): new_node=Node(new_data) if self.head is None: self.head=new_data return last=self.head while(last.next): last=last.next last.next=new_node llist1=Linkedlist() llist1.head=Node(1) second=Node(2) third=Node(3) llist1.head.next=second; second.next=third; llist1.append(8) llist1.printList() llist2=Linkedlist() llist2.append(10) llist2.append(20) llist2.append(30) llist2.printList()