In Python, how can I remove an object from a list of objects? Like this:
x = object()
y = object()
array = [x, y]
# Remove x
I've tried array.remove()
but it only works with a value, not a specific location in the array. I need to be able to delete the object by addressing its position (remove array[0]
).
array.remove(x)
, you don't need its position at all. After all, how would you even knowx
is in position 0 without knowingx
?