메뉴 여닫기
개인 메뉴 토글
로그인하지 않음
만약 지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.

튜플 리스트 딕셔너리 차이점,특징,사용예시

데브카페

튜플 딕셔너리 리스트 차이점 ,특징

List, Dictionary, Tuple 비교
Feature List Dictionary Tuple
**Definition** Unordered, mutable collection of key-value pairs Ordered, immutable sequence of items
**사용 문법** `{'key1': 'value1', 'key2': 'value2'}` | `(1, 2, 3)`
**Mutable?** Yes | No
**Indexed Access** Yes (by key) | Yes (by index)
**증복허용 여부 ** No (keys must be unique) | Yes
** 사용예시 ** Storing key-value pairs for fast lookup | Storing fixed collections that should not change
**언제 사용 하나?** When you need to associate values with unique keys | When you need an ordered and immutable collection
**Example Code**
my_list = [1, 2, 3]
print(my_list[0])  # Output: 1
my_dict = {'name': 'Alice', 'age': 25}
print(my_dict['name'])  # Output: Alice
my_tuple = (1, 2, 3)
print(my_tuple[1])  # Output: 2

Comments