[Python 공부] Data Types (mutable/immutable, set, mapping dictionary)
Mutable, Immutable 개념 Mutable 한 자료형은 변수의 값이 변해도 주소 값은 변하지 않지만, Immutable 한 것들은 변수의 값들이 변하면 주소 값이 변합니다. mutable : list, set, dict immutable : numbers, tuple, str, frozenset 아래 예시로 보면 더 직관적으로 이해할 수 있습니다. 출력 결과, 요소가 추가되어도 리스트 타입인 a의 id 값은 그대로이지만 숫자형인 b의 id는 변환되는 것을 확인할 수 있습니다. # mutable a = [1, 2, 3, 4, 5] print(a) print(id(a)) a.append(6) print(a) print(id(a)) # immutable b = 10 print(b) print(id(..
2023. 6. 6.