Ask coding questions

← Back to all posts
Python Pop Function
JayStrick

Hi,
I was just wondering how the pop function is used and if anyone can explain in detail how it works.

Thanks

Voters
JayStrick
Comments
hotnewtop
theangryepicbanana

This is something that you could always google https://www.geeksforgeeks.org/python-list-pop/ .

AkashMishra14

Python pop is inbuilt function used to remove element from list for a given index.

Suppose we have list of numbers

numbers = [10, 2, 15, 17]

We need to remove element at index 2. In such case we need to write code like

element_to_be_removed = numbers.pop(2)

It will remove number at index 2 (15 in list here)

Result list after removed element:
[10, 2, 17]

There is more such examples and commonly asked python questions with solution are on https://www.quizcure.com/topic/python