[Tutor] Doubly linked list

Steven D'Aprano steve at pearwood.info
Fri Oct 1 02:12:02 CEST 2010

On Thu, 30 Sep 2010 11:24:06 pm T MURPHY wrote:
> I was having trouble, where on the python site can i find steps on
> classes 

Google is your friend: googling for "python tutorial" brings up lots of 
tutorials that will help. Here's the first one:


> and making a doubly linked list, is there a help option for 
> linked lists.

Python doesn't supply a doubly-linked list, but it's easy to make your 
own. Here's a singly-linked list for you:

class Node(object):
    def __init__(self, data, next=None):
        self.data = data
        self.next = next

mylist = Node("a")
mylist.next = Node("b", Node("c"))

node = mylist
while node is not None:
    print node.data
    node = node.next

Steven D'Aprano

More information about the Tutor mailing list