The problem seems very easy, but unfortunately I can’t solve it.
Let list A = [[1,2,3], [4,5,6], [7,8,9], [10,11,12], [13,14,15]]
I want to create a new list by removing list [7,8,9]
The remove is not creating a new list: A.remove(2)
And set(A) - set([7,8,9]) throwing the following error.
TypeError: unhashable type: 'list'
Can someone please help me to solve the issue?
>Solution :
If you absolutely needs to remove based on indice and not value, it may be done with a list comprehension:
A = [value for i,value in enumerate(A) if i != 2]