How to print the elements of a linked list?

后端 未结 2 594
一生所求
一生所求 2020-12-19 12:17

I\'m dong a Node exercise on python today. I seem to have accomplished a part of it, but it is not a complete success.

class Node:
    def __init__(self, ca         


        
2条回答
  •  粉色の甜心
    2020-12-19 12:43

    Instead of calling str() on the node, you should access it's cargo:

    .
    .
    .    
    while node:
        nodelist.append(node.cargo)
        node = node.next
    .
    .
    .
    

提交回复
热议问题