튜플
-
7. 리스트와 튜플 사용하기Python/Grammar 2022. 12. 1. 12:51
# 1. 리스트 만들기 변수에 값을 저장할 때 대괄호로 묶어주면 리스트가 되고, 리스트 안의 각 요소(element)는 콤마로 구분해준다. 1-1. 리스트에 여러가지 자료형 저장하기 : 리스트는 문자열, 정수, 실수, 불 등 모든 자료형을 저장할 수 있으며, 여러 가지 자료형을 섞어서 저장해도 된다. >>> a = [1, 1.0, 'hello', True] >>> a [1, 1.0, 'hello', True] >>> type(a[2]) >>> type(a[3]) 1-2. range를 사용해 리스트 만들기 list(range(횟수)): 지정한 횟수(0~지정한 횟수 -1)만큼 숫자를 생성 list(range(시작, 끝)): 시작으로 지정한 숫자부터 끝으로 지정한 숫자 -1까지 연속된 숫자를 생성 list(r..