9
11

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.

Pythonでsort uniq的なことをしたい

Posted at
  • よくLinuxマシンでsort uniqして重複分を消していたので、同じ事をPythonでしたかった
  • 最初は下記のように書いていた
Befor.py
previousHoge = ""
    for hoge in HogeList :
        if (hoge != previousHoge):
            print hoge
        previousHoge = hoge
  • だがダサいので、もっとかっこいい書き方はないか探し、下記になった
After.py
sorted(set(HogeList), key= HogeList)
9
11
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
9
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?