@@ -0,0 +1,867 @@
+'''%0AImplement a set of stacks data structure: each stack has a maximum capacity.%0AIf one stack exceeds maximum capacity, the next element should go to a new stack.%0A'''%0Afrom __future__ import print_function%0A%0Aclass SetOfStacks:%0A%0A    def __init__(self):%0A        self.max = 5%0A        self.stacks = %5B%5D%0A%0A    def push(self, item):%0A        if self.stacks and len(self.stacks%5B-1%5D) %3C self.max:%0A            self.stacks%5B-1%5D.append(item)%0A        else:%0A            new_stack = %5Bitem%5D%0A            self.stacks.append(new_stack)%0A%0A    def pop(self):%0A        if self.stacks:%0A            popped = self.stacks%5B-1%5D.pop()%0A            if not self.stacks%5B-1%5D:%0A                self.stacks.pop()%0A            return popped%0A        else:%0A            return 'Stack Empty'%0A%0As = SetOfStacks()%0Afor i in range(12):%0A    s.push(i)%0Aprint(s.stacks)%0A%0Afor i in range(12):%0A    print(s.pop())%0Aprint(s.stacks)%0A%0A

set of stacks