pop method list python code example
Example 1: python pop
# Python list method pop() removes
# and returns last object or obj from the list.
# .pop() last element .pop(0) first element
my_list = [123, 'Add', 'Grepper', 'Answer'];
print "Pop default: ", my_list.pop()
> Pop default: Answer
# List updated to [123, 'Add', 'Grepper']
print "Pop index: ", my_list.pop(1)
> Pop index: Add
# List updated to [123, 'Grepper']
Example 2: pop list python
#pop removes the last element
li=[1,2,3,4,5]
li.pop()
#>>>[1, 2, 3, 4]
Example 3: .pop python
array.pop(2) # removes element at index 2