# # stack.py, a simple stack class # # class Stack: """ Provides a rudimentary stack class """ def __init__(self, initial_contents=[]): self.stack = [] for item in initial_contents: self.add(item) def is_empty(self): return self.stack == [] def add(self, item): self.stack.append(item) def remove(self): return self.stack.pop() def __str__(self): return "The stack contains: " + str(self.stack)