Python에서 list의 중복을 제거 하는 방법은 중복이 있는 list를 set으로 만들어 1차로 중복을 제거 하고, 다시 list로 만들면 된다.


>>> a=[0,0,1,1,2,3]

>>> set(a)

set([0, 1, 2, 3])

>>> a

[0, 0, 1, 1, 2, 3]

>>> list(set(a))

[0, 1, 2, 3]

 



http://partrita.blogspot.kr/2013/05/blog-post.html

'Development > Python' 카테고리의 다른 글

Python 에서 ++ --  (0) 2017.02.02
Python Random number  (0) 2017.02.01
Python 에서 Enum 사용하기  (0) 2017.01.25

+ Recent posts