set
-
파이썬 set개발 2022. 1. 15. 21:01
a = {1, 1, 2, 3, 3, 4, 5, 5} print(a) {1, 2, 3, 4, 5} print(a[0]) - error : 인덱스가 없다/순서가없다 중복x 순서x a = {} type(a) :: dict a = set() type(a) :: set a = [1, 1, 2, 3, 3, 4, 1, 5] print(a) :: [1, 1, 2, 3, 3, 4, 1, 5] b = set(a) print(b) :: {1, 2, 3, 4, 5} a = {1, 2, 3} b = {2, 3, 4} print(a.union(b)) # 합집합 print(a.intersection(b)) # 교집합 print(a.difference(b)) # 차집합 print(a.issubset(b)) # 부분집합 :: {1, ..