Beispiel #1
0
def sum_two_list(node1, node2, carry):
    if (node1 == None) and (node2 == None) and (carry == 0):
        return None
    result = Node()
    value = carry
    if node1 != None:
        value += node1.data
    if node2 != None:
        value += node2.data
    result.data = value % 10
    carry = value // 10
    if (node1 != None) or (node2 != None):
        node = sum_two_list(None if node1 == None else node1.next,
                            None if node2 == None else node2.next, carry)
        result.next = node
    return result
def test_node_cant_reset_data():
    new_node = Node(4)

    with pytest.raises(AttributeError):
        new_node.data = 6
Beispiel #3
0
 def testData(self):
     node = Node(data="data", next=None)
     self.assertEqual(node.data, "data")
     node.data = "new_data"
     self.assertEqual(node.data, "new_data")
 def testData(self):
     node = Node(data="data",next=None)
     self.assertEqual(node.data,"data")
     node.data = "new_data"
     self.assertEqual(node.data,"new_data")