A last-in-first-out (LIFO) structure. Push items on, pop them off in reverse order. Four core operations: push (add to top), pop (remove from top), peek (look at top without removing), and isEmpty (check if stack has elements).
stack = [] # use a list as a stack
vector<int> stack; // use vector as stack
var stack = new Stack<int>(); // Stack<T> class
Stack<Integer> stack = new Stack<>(); // Stack class
stack.append(5) # push 5 onto stack
stack.push_back(5); // push 5 onto stack
stack.Push(5); // push 5 onto stack
stack.push(5); // push 5 onto stack
top = stack.pop() # removes and returns top element
stack.pop_back(); // removes top element
int top = stack.back(); // get before popping if needed
int top = stack.Pop(); // removes and returns top element
int top = stack.pop(); // removes and returns top element
top = stack[-1] # view top element without removing
int top = stack.back(); // view top element without removing
int top = stack.Peek(); // view top element without removing
int top = stack.peek(); // view top element without removing
if not stack: # true if empty
print("empty")
if len(stack) == 0: # alternative check
print("empty")
if (stack.empty()) // true if empty
cout << "empty";
if (stack.size() == 0) // alternative check
cout << "empty";
if (stack.Count == 0) // true if empty
Console.WriteLine("empty");
if (stack.isEmpty()) // true if empty
System.out.println("empty");
len(stack) # number of elements
stack.size(); // number of elements
stack.Count; // number of elements (property)
stack.size(); // number of elements