pop()
noun
say it: “POP” /pɑp/
A list method that removes an item and hands it back: the last item with no argument, or the item at the position given.
What does pop() do?
pop() removes an item from a list and gives it back. With no argument it takes the last item.
orders = ["latte", "tea", "mocha"]
next_up = orders.pop()
print(next_up) # mocha
print(orders) # ['latte', 'tea']
In a sentence
- “pop() took the newest order off the end of the list and gave it to the barista.”
- “tasks.pop(0) removes and returns the first task.”
Level: Apprentice · More Python terms at this level
Updated