LoginSignup
20
12

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']
20
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
20
12