I am working out of How To Think Like A Computer Scientist. Here is the code for a module called node.py:
def printList(node): nodeList = [] while node: nodeList.append(node.cargo) node = node.next print nodeList def printBackward(node): if node == None: return head = node tail = node.next printBackward(tail) print head, class Node: def __init__(self, cargo=None, next=None): self.cargo = cargo self.next = next def __str__(self): return str(self.cargo) I'm trying to figure out how the printBackward function works. I understand it moves up a linked list until it reaches the end of the list. Why does it print every node? Shouldn't it just print the last one? _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor