-2

Suppose I have a list [[1,0], [14,12], [13,6], [1,0], [12,8], [13,6]] I want the output as [[1,0], [14,12], [13,6], [12,8]]

Please help me out with a solution code in python.

1
  • On a related note, searching "python 2d list remove duplicates" on Google pulls up plenty of relevant results. That should be the first port of call. Commented Mar 6, 2019 at 0:26

1 Answer 1

2

So you can put distinct values into a new list by iterating through the old list and checking the new one in a for loop. Like this:

lst = [[1,0], [14,12], [13,6], [1,0], [12,8], [13,6]]
newlist = []

for i in lst:
    if i in newlist:
        continue
    else:
        newlist.append(i)

print(newlist)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.