how to remove an element from a nested list?

后端 未结 8 1159
一生所求
一生所求 2020-12-17 00:37

if i have an nested list such as:

m=[[34,345,232],[23,343,342]]

if i write m.remove(345) it gives an error message saying elem

8条回答
  •  無奈伤痛
    2020-12-17 01:10

    If you want to remove only by indexes you can use this method

    m[0].pop(1)
    

    by this you can specify only the index. This is helpful if you know only the position you want to remove.

提交回复
热议问题