시퀀스 자료형
-
8. 시퀀스 자료형 사용하기Python/Grammar 2022. 12. 1. 13:01
# 1. 시퀀스 자료형의 공통기능 사용하기 파이썬에서는 리스트, 튜플, range, 문자열처럼 값이 연속적으로 이어진 자료형을 '시퀀스(sequence)'라고 한다. 참고로 시퀀스 자료형에는 위 4가지 자료형 이외에도 byte, bytearray가 있다. ※ 시퀀스 자료형을 만든 객체를 '시퀀스 객체'라고 하며, 시퀀스 객체에 들어있는 각 값을 '요소(element)'라고 한다. 1-1. 특정 값이 있는지 확인하기 : 시퀀스 객체에 in 연산자를 사용했을 때 특정 값이 있으면 True, 없으면 False를 반환한다. (not in 은 반대) 값 in 시퀀스객체 값 not in 시퀀스 객체 >>> a = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90] >>> 0 in a True >..