파이썬 목록 pop() 메서드
예시
fruit
목록 의 두 번째 요소를 제거합니다 .
fruits = ['apple', 'banana', 'cherry']
fruits.pop(1)
정의 및 사용
메서드 는 pop()
지정된 위치에서 요소를 제거합니다.
통사론
list.pop(pos)
매개변수 값
Parameter | Description |
---|---|
pos | Optional. A number specifying the position of the element you want to remove, default value is -1, which returns the last item |
더 많은 예
예시
제거된 요소를 반환합니다.
fruits = ['apple', 'banana', 'cherry']
x =
fruits.pop(1)
참고: 이 pop()
메서드는 제거된 값을 반환합니다.