List Pop in Python
Level 255 keystrokes
This removes and returns the last item from a list. The pop() method removes the last element and returns it.
Python code
# Create a list (can be used as a stack)1stack = [1, 2, 3]# pop() removes and returns the last element# item gets the value 3, stack becomes [1, 2]2item = stack.pop()# Print the popped item and remaining list3print(item, stack)Output
3 [1, 2]
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
,× 3(× 2)× 2=× 2.× 1[× 1]× 1