Development/Python
[Python][List] List 변경 기본 함수들
Best Junior
2020. 3. 22. 01:30
1. List i번째 인자 제거
test = [5, 6, 7, 8]
del test[1]
print(test)
# [5, 7, 8]
2. List i번째 위치에 x 라는 데이터 삽입
test = [5, 6, 7, 8]
test.insert(1, 9)
print(test)
# [5, 9, 6, 7, 8]
3. List x 라는 데이터 삭제
test = [5, 6, 7, 8]
test.remove(7)
print(test)
# [5, 6, 8]