Articles → Python → Pop Function In Python
Pop Function In Python
Purpose
Example
my_list = [1,2,3,4,5]
# Print the list
print("Before calling pop function", my_list)
# Calling the pop function will remove the top element from list
my_list.pop()
# Print the list
print("After calling pop function", my_list)
Output
Pop(Index)
my_list = [1,2,3,4,5]
# Print the list
print("Before calling pop function", my_list)
# Calling the pop function will remove the top element from list
my_list.pop(1)
# Print the list
print("After calling pop function", my_list)