Answers for "how to convert linked list to list in python"

0

how to convert linked list to list in python

# 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']
Posted by: Guest on June-02-2021

Code answers related to "how to convert linked list to list in python"

Python Answers by Framework

Browse Popular Code Answers by Language