+ 1
Bitwise XOR between these sets returns "set()": Why?
a = {0, 1} b = {1, 0} print(a ^ b) # prints "set()"
4 Antworten
+ 3
Md. Niamul Ahad Chowdhury ^ operator only includes the unique items from the sets, the items from set a, which don't exists in set b and the items from set b, which don't exist in set a.
All items in set a exist in set b and viceverca, so the combined set became empty.
+ 2
If it printed { }, you could not conclude from the output, whether the printed object was an empty dict or empty set, maybe that's why empty sets are represented as set().
+ 1
Seb TheS Yes, this is the answer I was hoping for. Thanks.
0
Seb TheS Okay, thank you. But why was it empty in the first place?