# our linked list class class LinkedListNode: def __init__(self, data): # class member for the data, initialize with argument data self.data = data # class member for the pointer to the next node, initialize to None (equivalent of null) self.nextNode = None # start by creating the first node start = LinkedListNode('a') # create another node another = LinkedListNode('b') # point the first at the second start.nextNode = another # create a third node third = LinkedListNode('c') # point the second at the third another.nextNode = third print('time to start printing stuff') # store the first node in a variable and walk through the nodes node = start while node is not None: # print the data print(node.data) # update the variable with the next node node = node.nextNode print('done printing stuff')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question