Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python List pop() Method


previous next AddThis Social Bookmark Button


Description:

This method removes and returns last object or obj from the list.

Syntax:

list.pop(obj=list[-1])

Parameters:

Here is the detail of parameters:

  • obj: optional parameter, index of the object to be removed from the list.

Return Value:

It returns removed object from the list.

Example:

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc'];

print "A List : ", aList.pop();
print "B List : ", aList.pop(2);

This will produce following result:

A List :  abc
B List :  zara


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names