파이썬 튜플 items
-
60 - (파이썬) 튜플, 이뮤터블 자료, 뮤터블 자료study with Q - 파이썬 2024. 6. 24. 20:41
# 람다: 매개변수로 함수를 전달하기 위해 함수 구문을 작성하는 것이 번거로울 때 함수를 간단하게 선언하는 방법. 1회용 함수를 만들어야 할 때 주로 사용한다. # 튜플: 함수와 함께 사용되는 리스트와 비슷한 자료형으로, 리스트와 다르게 한번 결정된 요소는 바꿀 수 없다. - 소괄호 기호를 사용해서 만든다. - 요소 접근 연산자를 이용해 각각의 요소에 접근할 수 있다.tup = (0,1,"two",True)print(tup)print(tup[0])print(tup[2])print(tup[3])>>>(0, 1, 'two', True)0twoTrue - 요소를 하나만 가지는 튜플을 만드려면 다음과 같이 쉼표를 넣어서 선언한다. (쉼표를 넣지않으면 숫자, 문자열 등에 괄호를 감싼 것이라고 인식한다.)# 이렇..