how to convert linked list to list in python

Solutions on MaxInterview for how to convert linked list to list in python by the best coders in the world

showing results for - "how to convert linked list to list in python"
Liam
04 Sep 2017
1# credit to the Stack Overflow user in the source link
2
3linked_list = {'a':'b', 'b': 'c', 'c': 'd', 'd': None}
4def next_ll(state=['a']):
5  value = state[0]
6  if value is not None:
7    state[0] = linked_list[value]
8    return value
9
10[x for x in iter(next_ll, None)]
11>>> ['a', 'b', 'c', 'd']