Q:

Return a new set of identical items from two sets using python programming

belongs to collection: Python Set Exercises

0

Return a new set of identical items from two sets

Given:

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

Expected output:

{40, 50, 30}

All Answers

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

Hint:

Use the intersection() method of a set.

Solution:

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

print(set1.intersection(set2))

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

total answers (1)

Write a Python program to return a new set with un... >>
<< Given a Python list, Write a program to add all it...