튜플은
순서가 지정된 항목 모음을 저장하는 데 사용되는 Python의 불변 데이터 구조입니다.
튜플은 리스트와 유사하지만 대괄호 대신 괄호로 묶습니다. 튜플도 일단 생성되면 변경할 수 없습니다.
예시코드
# Create a tuple
my_tuple = (1, 2, 3)
# Print the tuple
print(my_tuple) # Output: (1, 2, 3)
# Access individual elements
print(my_tuple[1]) # Output: 2
# Tuples cannot be changed once they have been created
my_tuple[1] = 0 # Output: TypeError: 'tuple' object does not support item assignment
반응형
'기타' 카테고리의 다른 글
[Python] dictionary (0) | 2023.01.27 |
---|---|
[Python] set (0) | 2023.01.27 |
[Python] list (0) | 2023.01.27 |
[Python] 변수와 함수 (0) | 2023.01.27 |
R프로그램과 파이썬의 비교 (0) | 2023.01.24 |