[python] 파이썬 집합에서 다른 집합과의 합집합을 구하는 방법은 무엇인가요?
# Using union() method
set1 = {1, 2, 3}
set2 = {3, 4, 5}

union_set = set1.union(set2)
print(union_set)  # 출력: {1, 2, 3, 4, 5}

# Using | operator
union_set = set1 | set2
print(union_set)  # 출력: {1, 2, 3, 4, 5}

이 코드를 실행하면 두 집합의 합집합이 출력됩니다.