[python] list 삭제 메서드 차이 + 요소 추가
list 원소 삭제 index로 제거 1️⃣ del a = [1, 2, 3, 4, 5, 6, 7] del a[1] print(a) # [1, 3, 4, 5, 6, 7] 2️⃣ pop : list.pop(인덱스) user_1 = ['수진', '민호', '나빈'] user_1.pop(1) # '민호' 삭제 print(user_1) # ['수진', '나빈'] 값으로 제거 1️⃣ remove : list.remove(삭제할 원소) a = [1, 2, 3, 4, 5, 6, 7] a.remove(3) print(a) # [1, 2, 4, 5, 6, 7] a.remove(9) # Traceback (most recent call last): # File "", line 1, in # ValueError: list.r..
2023. 6. 30.