Q:

Write a Python program to return a new set with unique items from both sets by removing duplicates.

0

Get Only unique items from two sets

Write a Python program to return a new set with unique items from both sets by removing duplicates.

Given:

set1 = {10, 20, 30, 40, 50}
set2 = {30, 40, 50, 60, 70}

Expected output:

{70, 40, 10, 50, 20, 60, 30}

Note: set is unordered so not necessary this will be the order of the item.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Hint:

Use the union() method of a set.

Solution:

set1 = {10, 20, 30, 40, 50}
set2 = {30, 40, 50, 60, 70}

print(set1.union(set2))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now