📌  相关文章
📜  如何在python代码示例中将链表转换为列表

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

代码示例1
# credit to the Stack Overflow user in the source link

linked_list = {'a':'b', 'b': 'c', 'c': 'd', 'd': None}
def next_ll(state=['a']):
  value = state[0]
  if value is not None:
    state[0] = linked_list[value]
    return value

[x for x in iter(next_ll, None)]
>>> ['a', 'b', 'c', 'd']