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


Picture showing the output of the Pop function in python



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)




Picture showing removing the element from any position using the pop function



Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, April 10, 2019
 
Updated On  -  Friday, May 10, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250