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']