Web Analytics

Python set.difference() Method

Set Method Difference

The difference() method returns a set that contains the difference between two sets.

Meaning: The returned set contains items that exist only in the first set, and not in both sets.

Syntax

set.difference(set)

Parameters

Parameter Description
set Required. The set to check for differences in

Return Value

A new set containing the difference.

Example

Using the difference() method:

Output
Click Run to execute your code

Related Functions