Q1:
I have an arraylist
x= [[1,2,-1],[1,-1,0],[-1,0,1]]
finally I want to get x = [[1,2,-1],[1,-1,0]]
because [1,-1,0]
and [-1,0,1]
are the same but just different order.
Q2:
For
temp = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
The same idea, I want to get temp = [[0,0,0]]
, which means droping all the other duplicates in the arraylist just like Q1.
My code does not work. It says list index out of range, but I use temp2
to len(temp1)
changes.....why?
temp1 = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
temp2 = temp1
for i in range(0, len(temp1)):
for j in range(i+1, len(temp1)):
if(set(temp1[i]) == set(temp1[j])):
temp2.remove(temp2[i])