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('重複無し')
Go to list of users who liked
More than 3 years have passed since last update.
set型は重複を削除してくれることを利用する。
下記の例だとtest1-5の変数にそれぞれ何らかの値が入っている想定。
例えばtest1とtest4が全く同じ値の時とかに重複判定される。
a = {test1, test2, test3, test4, test5}
b = [test1, test2, test3, test4, test5]
if len(a) != len(b):
print('重複あり')
else:
print('重複無し')
Register as a new user and use Qiita more conveniently
Go to list of users who liked