1my_list = [123, 'Add', 'Grepper', 'Answer']
2my_list.pop()
3-->[123, 'Add', 'Grepper'] #last element is removed
4
5my_list = [123, 'Add', 'Grepper', 'Answer']
6my_list.pop(0)
7-->['Add', 'Grepper', 'Answer'] #first element is removed
8
9my_list = [123, 'Add', 'Grepper', 'Answer']
10any_index_of_the_list = 2
11my_list.pop(any_index_of_the_list)
12-->[123, 'Add', 'Answer'] #element at index 2 is removed
13 #(first element is 0)
1# Python list method pop() removes
2# and returns last object or obj from the list.
3# .pop() last element .pop(0) first element
4
5my_list = [123, 'Add', 'Grepper', 'Answer'];
6print "Pop default: ", my_list.pop()
7> Pop default: Answer
8# List updated to [123, 'Add', 'Grepper']
9print "Pop index: ", my_list.pop(1)
10> Pop index: Add
11# List updated to [123, 'Grepper']
1# programming languages list
2languages = ['Python', 'Java', 'C++', 'French', 'C']
3
4# remove and return the 4th item
5return_value = languages.pop(3)
6print('Return Value:', return_value)
7
8# Updated List
9print('Updated List:', languages)
1# Python pop list
2
3some_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # normal python list
4print(some_list) # prints [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
5
6some_list.pop() # pop() is used to pop out one index from a list (default index in pop is -1)
7print(some_list) # prints [1, 2, 3, 4, 5, 6, 7, 8, 9]
8
9=====================================================
10# Output:
11[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
12[1, 2, 3, 4, 5, 6, 7, 8, 9]