Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




intersection_update( ) FUNCTION


As the name suggests, the 'intersection_update( )' Function takes the values from both the Sets and only value that is common in both Sets are taken.


Since, 'Kriti' is the common value in both the Sets, 'intersection_update( )' Function would just take the name 'Kriti'.


Example :


x = {"Mohan", "Kriti", "Salim"}
y = {"Sia", "Andrew", "Kriti"}
x.intersection_update(y)
print(x) 


Output :



  {'Kriti'}

So, in the above code we have created a 'Set' and initialised to the variable 'x'.


x = {"Mohan", "Kriti", "Salim"}

java_Collections

Then what we have done is, put the names, 'Sia', 'Andrew' and 'Kriti' in another set 'y'.


y = {"Sia", "Andrew", "Kriti"}

java_Collections

And used the 'intersection_update( )' Function next.


x.intersection_update(y)

And since, 'Kriti' is present in both the Sets, only 'Kriti' will be present in the Set 'x'


java_Collections

And we get the below output,


{'Kriti'}