Python list method pop() removes and returns the last object or obj from the list.
Following is the syntax for pop() method -
list.pop(obj = list[-1])
This method returns the removed object from the list.
Example
The following example shows the usage of pop() method.
#!/usr/bin/python aList = [123, 'xyz', 'zara', 'abc']; print "A List : ", aList.pop() print "B List : ", aList.pop(2)
When we run the above program, it produces the following result -
A List : abc B List : zara
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.