Post

@PythonDvz Error: with set is permitted only the method union() otherwise | operator, not the sum with +
set_sum = set1 | set2
set_sum = set.union(set2)
English

@PythonDvz Set1 = {1,2,3}
Set2= {4,5,3,2}
Print( len(Set1 + Set2))
Set1 + Set2 = {1,2,3,4,5}
[Sets doesn'tacceptduplicate]
len(Set1 + Set2) = 5
Therefore;
Print( len(Set1 + Set2)) = 5
Option a
English

@PythonDvz No duplicates in Set.
So merge of 2 sets would lead to holding 1,2,3,4,5
Option A
English

@PythonDvz Error: TypeError: unsupported operand type(s) for +: 'set' and 'set'
d.Error
I admit, I wrote the Python script.
English

@PythonDvz Option d. Error is the correct answer.
You can not use '+' operator to concatenate two sets, instead of '+' operator you use union() method or '|'.
So, correct code should be either
print(len(set_1 | set_2)) or print(len(set_1.union(set_2)))
both return 5.
English





