Skip to content

Instantly share code, notes, and snippets.

@Gomi-coder
Created February 15, 2023 06:14
Show Gist options
  • Save Gomi-coder/986ea71996f77b0ec933b0bc200746ff to your computer and use it in GitHub Desktop.
Save Gomi-coder/986ea71996f77b0ec933b0bc200746ff to your computer and use it in GitHub Desktop.
python-list의 요소 삭제
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