Created
February 15, 2023 06:14
-
-
Save Gomi-coder/986ea71996f77b0ec933b0bc200746ff to your computer and use it in GitHub Desktop.
python-list의 요소 삭제
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user_1 = ['Jason', 'Smith', 'Kevin'] | |
#del 리스트명[인덱스] | |
del user_1[1] | |
del user_1[1:3]#1,2번 인덱스 삭제 | |
#리스트명.pop(인덱스) | |
user_1.pop(1) | |
user_1.pop() | |
#리스트.remove(값) | |
user_1.remove('Smith') #가장 먼저 발견된 요소 하나만 지워줌. | |
while 'Smith' in user_1: | |
user_1.remove('Smith') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment