注册 登录
编程论坛 Python论坛

Python嵌套类实现单链表

bubble_soup 发布于 2018-04-11 13:20, 1290 次点击
def append(self, item):
        if self.head is None or self.head is None:
            return None
        node = head.next
        while node.next
            node = node.next
        node.next = item
==========================
现在外部类是LinkedList:
init方法中有head属性。
内层类是Node。
init方法有data、next属性。
关键是append方法定义在外层,内部的next不可见。
问题是怎么样修改该方法让append可行??
0 回复
1