Python List pop() Method

Python List pop() Method

  • The pop() method removes the item at the given index from the list and returns the removed item.

Syntax

  • list.pop(index)

Parameter Values

  • The pop() method takes a single argument (index).

  • The argument passed to the method is optional. If not passed, the default index -1 is passed as an argument (index of the last item).

  • If the index passed to the method is not in range, it throws IndexError: pop index out of range exception.

 

 

 

 

 

Comments