1 ответ
+ 2
Check these operators
first = {2, 3, 3, 5, 9, 7}
second = {4, 5, 6, 7, 8}
print(first | second)
print(first & second)
print(first - second)
print(second - first)
print(first ^ second)
output:
{2, 3, 4, 5, 6, 7, 8, 9}
{5, 7}
{9, 2, 3}
{8, 4, 6}
{2, 3, 4, 6, 8, 9}
#(first | second) - return added without duplicates
#(first & second) - return what is common in both
#(first - second) - return what is unique in first
#(second - first) - return what is unique in second
#(first ^ second) - return what is unique in both