class List_Node: # self.data # self.next # constructor def __init__(self, data): self.data = data self.next = None # Called when printing the object def __str__(self): return str(self.data) def go_wave(self): self.data = self.data + " -- go wave!" def print_linked_list_pretty(self): # self is front node of list current=self while(current!=None): print current, "->", current = current.next print "None" def print_linked_list(L): # L is front node of list current=L while(current!=None): print current # prints current.__str__() current = current.next x = List_Node('a') print x.data print x # calls __str__() method x.go_wave() print x print # Create L: 'a'->'b'->'c'->'d'->None L=List_Node('a') # L: 'a' -> None L.next=List_Node('b') L.next.next=List_Node('c') L.next.next.next=List_Node('d') print_linked_list(L) L.print_linked_list_pretty()