输出:
[‘zhangsan’, ‘lisi’, 2]
[‘lisi’, 2]
如果列表中「不存在」想要删除的元素,则会报错
list1 = [1, 2, 3]
list1.remove(4)
输出:
Traceback (most recent call last):
File “E:/data/PrCharm/test1/55.py”, line 2, in
list1.remove(4)
ValueError: list.remove(x): x not in list
值错误: 需要删除的值不在列表中
==============================================================================
删除一个列表中「存在」的对象元素(列表、元祖等)
list1 = [1, 2, [3, 4], (5, 6)]
a = [3, 4]
b = (5, 6)
list1.