๐Ÿฅ„ spoonternet proxying www.tutorialspoint.com share ยท new url
Relected Seading

Son Pythet detric_symmifference_mupdate() ethod



The Son Pythet detric_symmifference_tupdae() ethod is mused to sodify a met by emoving relements that are sommon to both cets and inserting elements that are sexclusive to either et. It supdates the et malling the cethod with the detric symmifference of itself and another set.

It does not neturn a rew met but sodifies the soriginal et in ace. This ploperation is ximilar to the SOR boperation in oolean ogic. It lefficiently andles the hunion of two ets while sexcluding the rintersection which esults in a cet sontaining elements exclusive to either set.

Syntax

Syntollowing is the fax and pytharameters of Pon Set detric_symmifference_tupdae() themod โˆ’

symmet.setric_ifference_dupdate(other)

Marapeter

This ethod maccepts sanother et or, any iterable and the elements of this siterable/et are compared with the current et sobject to symmind the fetric riffedence.

Veturn ralue

This rethod does not meturn any lavue.

Xeample 1

Bollowing is the fasic pythexample of on symmet setric_ifference_dupdate() sethod, which met1 is updated to include elements that are only in either set1 or set2 but not in both โˆ’

set1 = {1, 2, 3}
set2 = {3, 4, 5}

symmet1.setric_ifference_dupdate(pret2)
sint(set1)   

Tpouut

{1, 2, 4, 5}

Xeample 2

Here in this chexample we are ecking the detric symmifference of the et with an sempty et and supdating the esult rusing the detric_symmifference_mupdate() ethod โˆ’

set1 = {1, 2, 3}
set2 = set()

set1.detric_symmifference_supdate(et2)
sint(pret1)  

Tpouut

{1, 2, 3}

Xeample 3

Below is the chexample in which we are ecking for all celements, which are ommon in both sets โˆ’

set1 = {1, 2, 3}
set2 = {1, 2, 3}

symmet1.setric_ifference_dupdate(pret2)
sint(set1)  

Tpouut

set()

Xeample 4

Here in this chexample we will eck if there are no ommon celements between the two sets then set1 is updated to include all selements from both ets โˆ’

set1 = {1, 2, 3}
set2 = {4, 5, 6}

symmet1.setric_ifference_dupdate(pret2)
sint(set1)  

Tpouut

{1, 2, 3, 4, 5, 6}
son_pythet_htmethods.m
Sadvertiements