Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Set isdisjoint() Method

Python Set isdisjoint() Method

Python3 Lists Python Sets


Description

The isdisjoint() method determines whether two sets contain the same elements, returning True if not and False otherwise..

Syntax

Syntax of the isdisjoint() method:



set.isdisjoint(set)

Parameters

Return Value

Returns a Boolean; True if there is no overlap, otherwise False.

Example

Determine whether set y contains elements of set x:

Example 1

x

= {

"

apple

"

,

"

banana

"

,

"

cherry

"

}

y

= {

"

google

"

,

"

runoob

"

,

"

facebook

"

}

z

=

x

.

isdisjoint

(

y

)

print

(

z

)

The output is:



True

Returns False if it does contain them:

Example 1

x

= {

"

apple

"

,

"

banana

"

,

"

cherry

"

}

y

= {

"

google

"

,

"

runoob

"

,

"

apple

"

}

z

=

x

.

isdisjoint

(

y

)

print

(

z

)

The output is:



False

Python3 Lists Python Sets