파이썬 자료구조 set
·
Python
롤케이크 자르기 (해시, Counter, set) karla.tistory.com # add() 요소 추가 my_set = {10, 20, 30} my_set.add(40) # {10, 20, 30, 40} # remove() 요소 삭제 my_set = {10, 20, 30} my_set.remove(10) # {20, 30} # Intersection (교집합) set1 = {3, 4, 9, 1, 4, 2, 5, 6, 7, 8, 10} set2 = {5, 6, 7, 8, 9, 10} # {5, 6, 7, 8, 9, 10} # Union (합집합) set1 = {3, 4, 9, 1, 4, 2, 5, 6, 7, 8, 10} set2 = {5, 6, 7, 8, 9, 10} print(set1 | set2) ..