作为练习,我想创建自己的节点/列表类。无论如何,我不明白如何将节点添加到列表中......这是我的代码:
class Node:
def __init__(self, value):
self.element = value
self.nextEl = None
def getEl(self):
return self.element
def getNext():
return self.nextEl
class List:
def __init__(self, fnode):
self.firstNode = fnode
def add(self, newNode):
def printList(self):
temp = self.firstNode
while (temp != None):
print temp.element
temp = temp.nextEl