1. 빈 리스트 확인
>>> list1 = []
>>> list2 = [1,2,3]
>>> if not list1:
>>> print("list1 is empty")
>>>
>>> if list2:
>>> print("list2 is not empty")
list1 is empty
list2 is not empty
2. 리스트에 요소 추가
append() : 리스트의 마지막에 원소를 추가하는 연산을 수행함 >>> a = [1,2,3]
>>> a.append(4)
>>> a
[1, 2, 3, 4]
>>> a.append([5,6])
>>> a
[1, 2, 3, 4, [5, 6]]
3. 리스트에 요소 삽입
insert(index ,element) : 리스트의 중간에 원소를 추가하는 연산 >>> a = [1,2,3]
>>> a.insert(0,4)
>>> a
[4, 1, 2, 3]
4. 리스트 요소 꺼내기
pop(index) : 매개변수로 인덱스를 전달하면 리스트의 인덱스 위치에 있는 요소를 리턴하고, 해당 요소는 삭제함. 매개변수 값이 없는 경우 맨 마지막 요소를 리턴하고 삭제함. >>> a = [1,2,3]
>>> a.pop()
3
>>> a
[1, 2]
>>> a = [1,2,3]
>>> a.pop(1)
2
>>> a
[1, 3]
출처
(책) 파이썬으로 배우는 자료 구조의 핵심원리
https://wikidocs.net/14
https://planharry.tistory.com/14https://codechacha.com/ko/python-check-empty-list/