how to convert linked list to list in python code example
Example: 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']