📚Programming/Python
[파이썬] List 자료형
coding_yoon
2022. 9. 29. 18:18
1️⃣ 리스트 자료형
: 리스트란? 변수 여러개를 묶는 역할
: 하나의 변수에 여러 개의 값을 관리할 때 사용
1, 3, 5, 7, 9 라는 숫자 모음
>>> odd = [1, 3, 5, 7, 9]
리스트명 = [요소1, 요소2, 요소3,...]
>>> a = [] # 빈값
>>> b = [1, 2, 3] # 숫자
>>> c = ['Life', 'is', 'too', 'short'] # 문자
>>> d = [1, 2, 'Life', 'is'] # 숫자 + 문자
>>> e = [1, 2, ['Life', 'is']]
>>> print(e[0])
# 결과
1
>>> print(e[2])
# 결과
['Life', 'is']
>>> print(e[2][0])
# 결과
Life