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