Pythonで順序を保持したままsetする方法 2024年1月3日 / 1 min read View more blogs with the tag python Table of Contents #はじめに #方法 はじめに Pythonで順序を保持したままsetする方法のご紹介です。 方法 sorted メソッドを挟むことで、順序を保持することができます。 lst = ['john', 'alice', 'joe']sorted(set(lst), key=lst.index)# -> ['john', 'alice', 'joe']