Source Code:
(back to article)
# Removing and returning the last item of a list my_list = [1, 2, 3, 4, 5] removed_item = my_list.pop() print(my_list) # [1, 2, 3, 4] print(removed_item) # 5 # Removing and returning a specific item from a list my_list = [1, 2, 3, 4, 5] removed_item = my_list.pop(1) print(my_list) # [1, 3, 4, 5] print(removed_item) # 2
Result:
Report an issue