-2
def unique(a):
    for i in a:
        set(a)
set([1,2,3])

print unique([1,1,2,3,2])

Define a function unique(a) that takes a list of numbers a and returns a new list where each element of a occurs only once. The new list should have its elements in the same order as they appear in a. Your function must use a set.

  • possible duplicate of [How do you remove duplicates from a list in Python whilst preserving order?](http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order) – Ben Oct 12 '14 at 20:07
  • Welcome to Stack Overflow. It's inconsiderate of other people's time to just dump your question like this. Please take some time to read [the rules](http://stackoverflow.com/help/how-to-ask). – Veedrac Oct 14 '14 at 21:47

1 Answers1

1

set is what you want :

>>> a=[1,1,2,2,3,3]
>>> set(a)
set([1, 2, 3])
Mazdak
  • 105,000
  • 18
  • 159
  • 188