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 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]
1my_list = [1,2,3,4]
2
3# Default pop
4my_list.pop()
5print(f'Default : {my_list}')
6
7# Index pop
8my_list.pop(1)
9print(f'By Index : {my_list}')