📜  从链表中删除所有元素 python 代码示例

📅  最后修改于: 2022-03-11 14:45:55.330000             🧑  作者: Mango

代码示例1
def deleteAllNodes(self):

  #1 & 2. create a temp node, if the head is not  
  #   null make temp as head and move head to head 
  #   next, then delete the temp, continue the 
  #   process till head becomes null
  while (self.head != None):
    temp = self.head
    self.head = self.head.next
    temp = None

  print("All nodes are deleted successfully.")