0
1

More than 3 years have passed since last update.

重複確認

Posted at

set型は重複を削除してくれることを利用する。
下記の例だとtest1-5の変数にそれぞれ何らかの値が入っている想定。
例えばtest1とtest4が全く同じ値の時とかに重複判定される。

test.py
a = {test1, test2, test3, test4, test5}
b = [test1, test2, test3, test4, test5]
if len(a) != len(b):
    print('重複あり')
else:
    print('重複無し')
0
1
1

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
0
1