Python Set difference() Method

Python Set difference() Method

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

Note :- If A and B are two sets. The set difference of A and B is a set of elements that exists only in set A but not in B. For example:

                                                 If A = {1, 2, 3, 4} 

                                                 B = {2, 3, 9} 

                                                 Then, A - B = {1, 4} 

                                                  B - A = {9}

Syntax

  • set.difference(set)

Parameter Values

  • set -The set to check for differences in set.

 

 

 

Comments