def __init__(self, list): previous = None for data in list: node = Node() node.number = data if previous != None: previous.nextPointer = node previous = node if self.head == None: self.head = node
def reverse(node): if(node == None): print("Called reverse on None") print("reverse is returning from being called on None") return None else: print("Called reverse on " +str(node.number)) reverseOfRemainder = reverse(node.nextPointer) if node.nextPointer == None: print("reverse returned from being called on None") else: print("reverse returned from being called on "+ str(node.nextPointer.number)) newAppend = Node() newAppend.number = node.number newAppend.nextPointer = None reverseList = append(reverseOfRemainder,newAppend) print("reverse is returning from being called on "+ str(node.number)) printList(reverseList) return reverseList
def test_node_numberStoresData(self): node = Node() expected = "expected result" node.number = "expected result" self.assertEquals(expected, node.number, "Setting a Node's data should succeed")
def test_removeNext_nextIsNull_succeeds(self): node = Node() node.nextPointer = None node.removeNext()