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



Click to Enlarge


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)





Click to Enlarge


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