[Python] remove list item. 리스트에서 아이템 삭제 방법(clear, pop, remove, del)
Remove item from list 리스트에서 아이템 삭제하는 방법 # 삭제 관련 list function clear() : 모든 item 삭제 pop() : index 로 item을 가져오면서 삭제 remove() : value 로 item 삭제 # python function del : index 로 삭제 1. clear() my_list = [0,1,2,3,4,5] my_list.clear() print(my_list) # [] 2. pop() my_list = ['a', 'b', 'c', 'd', 'e'] one = my_list.pop(2) # index 2 의 값을 빼옴 print(one) # c print(my_list) # ['a', 'b', 'd', 'e'] # 뒤에서 인덱스 two ..
2021. 3. 25.