Q:

Python: Removing entries of one list by duplicates of another list

I have two python lists. In the first list I want to remove all duplicates and in the second list I want to remove the items that are at the places of the duplicates in the first list.
For example from these two lists
list_1 = [1,1,2,3]
list_2 = [a,b,c,d]

I want to generate these two:
result_1 = [1,2,3]
result_2 = [a,c,d]

I don't care, whether result_2=[a,c,d] or result_2=[b,c,d].
Of course I can think of ways to solve this with simple for loops, but I thought maybe someone can come up with a more elegant solution.

A:

Here you go. Simple and elegant:
>>> list_1 = [1,1,2,3]
>>> list_2 = ['a','b','c','d']
>>> temp = dict(zip(list_1,list_2))
>>> result_1 = temp.keys()
>>> result_2 = temp.values()
>>> result_1
[1, 2, 3]
>>> result_2
['b', 'c', 'd']

Since dictionary creates unique keys - you get according values in second list from your zip().

