Difference And Symmetric Difference SET Method With Exercises
Rushikesh J.
QA Automation Engineer @Vinz Global | Robot Framework | Manual Testing, Automation Testing | Python | Selenium | GIT | JIRA | Immediate Joiner | API Testing Using Postman | Jenkins
SET : Difference Method
Working:? It return element that are present in first set but same element absent in 2nd set. if we have two set A and B. It return a set which contain all the element of A that absent in B set.
Syntax:
set1.difference(set2)
Example:
a = {3,5,6}
b = {5,2,7}
c = a.difference(b)
Result:
{3,6}
SET : Symmetric Difference Methods
Working:? It return a set that contain elements of both set except those items that are duplicated in both set.
Syntax:
set1. symmetric_difference(set2)
Example:
a = {3,5,6}
b = {5,2,7}
c = a.symmetric_difference(b)
Result:
{3,6,2,7}