Python Set isdisjoint()メソッド
例
x
セット内のアイテムがセット内に存在しない場合はTrueを返します
y
。
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "facebook"}
z = x.isdisjoint(y)
print(z)
定義と使用法
このisdisjoint()
メソッドは、両方のセットにアイテムが存在しない場合はTrueを返し、それ以外の場合はFalseを返します。
構文
set.isdisjoint(set)
パラメータ値
Parameter | Description |
---|---|
set | Required. The set to search for equal items in |
その他の例
例
両方のセットにアイテムが存在しない場合はどうなりますか?
両方のセットに1つ以上のアイテムが存在する場合は、Falseを返します。
x =
{"apple", "banana", "cherry"}
y = {"google",
"microsoft", "apple"}
z = x.isdisjoint(y)
print(z)