#!/usr/bin/python3
#在链表的末端插入新的节点。
class Node():
def init(self,data=None):
self.data=data
self.next=None
class LinkedList():
def init(self):
self.head=None
def printList(self):ptr=self.headwhile ptr:print(ptr.data)ptr=ptr.nextdef ending(self,newdata):newNode=Node(newdata)if self.head==None:self.head=newNodereturnlastPtr=self.headwhile lastPtr.next:lastPtr=lastPtr.nextlastPtr.next=newNode
link=LinkedList()
link.head=Node(5)
n2=Node(15)
n3=Node(25)
link.head.next=n2
n2.next=n3
link.printList()
print(“新的链表”)
link.ending(100)
link.printList()