The 'union( )' Function takes the values from both the sets and joins them.
x = {"Mohan", "Kriti", "Salim"} y = {"Sia", "Andrew", "Kriti"} z = x.union(y) print(z)
So, in the above code we have created a 'Set' and initialised to the variable 'x'.
Then what we have done is, put the names, 'Sia', 'Andrew' and 'Kriti' in another set 'y'.
And used the 'union( )' Function to join the Set 'x'(With values 'Kriti', 'Mohan' and 'Salim') with the Set 'y'(With values 'Sia', 'Andrew' and 'Kriti').
And assign it to a new variable 'z'.
And since, 'Kriti' is present in both the Sets, 'Kriti' will be added once. Else it might cause a dupicate entry.
And we get the below output,