setを|で結合すると和集合が作成される
どういうこと?
code:python
set1 = {1, 2, 3}
set2 = {4 ,5, 6}
union_set = set1 | set2
print(union_set) # {1, 2, 3, 4, 5, 6} が出力される
この挙動はunionと同じ
code:python
set3 = {7, 8, 9}
set4 = {10, 11, 12}
union_set = set.union(set3, set4)
print(union_set) # {7, 8, 9, 10, 11, 12} が出力される