python dict pop code example
Example 1: python pop element
my_list = [123, 'Add', 'Grepper', 'Answer']
my_list.pop()
-->[123, 'Add', 'Grepper'] #last element is removed
my_list = [123, 'Add', 'Grepper', 'Answer']
my_list.pop(0)
-->['Add', 'Grepper', 'Answer'] #first element is removed
my_list = [123, 'Add', 'Grepper', 'Answer']
any_index_of_the_list = 2
my_list.pop(any_index_of_the_list)
-->[123, 'Add', 'Answer'] #element at index 2 is removed
#(first element is 0)
Example 2: python dictionary pop
value = dict_a.pop(key)
Example 3: dict pop
dictionary.pop(key, default)
Example 4: python dictionary pop key
my_dict.pop('key', None)