ar.pop in 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: python list.pop()
my_list = [1,2,3,4]
# Default pop
my_list.pop()
print(f'Default : {my_list}')
# Index pop
my_list.pop(1)
print(f'By Index : {my_list}')