21
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

list 元の順番で重複を排除

Last updated at Posted at 2018-06-22

リストの作成

>>> list = ['a', 'b', 'c', 'a']
['a', 'b', 'c', 'a']

通常の重複排除

>>> set(list)
{'b', 'a', 'c'}

元の順番を保持した重複排除

>>> sorted(set(list), key=list.index)
['a', 'b', 'c']
21
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?