How to remove a specific element from a python list?
Question: I want to remove an A element using a B array of IDs, given the specific
scalar ID 'C'

In matlab I can do this:

    
    
    A(B == C) = []
    

This is an example of my code:

    
    
     boxes = [[1,2,20,20],[4,8,20,20],[8,10,40,40]]
     boxIDs = [1,2,3]
    
    
    IDx = 2
    

I want to delete the second box completely out of the list.

How can I do this in python? I have numpy.


Answer: without import `numpy` you can `pop` out the element. try:

    
    
    boxes = [[1,2,20,20],[4,8,20,20],[8,10,40,40]]
    IDx = 1
    pop_element = boxes.pop(IDx)
    

the list `boxes` now is `[[1, 2, 20, 20], [8, 10, 40, 40]]` and `pop_element`
is `[4, 8, 20, 20]`

PS: in python indexes start from `0` instead of `1`.

