有没有人能够帮我具体讲解python链表删除的操作啊
难以理解
ps:以下面例子讲解,谢谢,怕没有代码看不懂
代码如下:
data=[['头节点',5],['甲',3],['乙',6],['丙',4],['丁',-1],['戊',2],['己',8],['庚',1],['辛',7]]
head=0
leng=len(data)
a=input('请输入删除的数据')
p=head
while a!=data[p][0] and p!=-1:
q=p
p=data[p][1]
if p==-1:
print('没有要删除的数据')
else:
data[q][1]=data[p][1]
p=head
while p!=-1:
print(data[p][0]+'→',end='')
p=data[p][1]