Returns a new set with all items from both sets by removing duplicates in Python

Given :

 set1 = {10, 20, 30, 40, 50}

set2 = {30, 40, 50, 60, 70}

Expected output:

{70, 40, 10, 50, 20, 60, 30}
Code :
set1 = {10, 20, 30, 40, 50}
set2 = {30, 40, 50, 60, 70}
set3=set1.union(set2)
print(set3)

Comments