set.copy() in python


"copy()" function is used to copy the elements from one set to another set.




Syntax:




set.copy()







Example-1
n = {10, 20, 30, 10}

a = n.copy()

print(a)


Output



{10, 20, 30}







Example-2
n = {10, 20, 30, 40, 10, 30}

a = n.copy()

print(a)


Output



{40, 10, 20, 30}







Example-3
n = {"A","B","AB","A"}

a = n.copy()

print(a)


Output



{'AB', 'B', 'A'}