コード例 #1
0
from linkedList import LinkedList

data = LinkedList()

data.append('A')
data.append('B')
data.append('C')
data.append('D')
data.append('E')
data.append('F')
data.append('G')

data.show()

# This problem is quite strange because it cannot be solved for the last node of a LL,
# or the last 2 nodes if a 'tail' is implemented in the LL

# I've given a solution here which works for any node other than those ive just described

def deleteNode(node):
    node.data = node.next.node.data
    node.next_node = node.next_node.next_node

print 'deleting node index 2'
deleteNode(data.getNode(2))
data.show()