from Stack import Stack class RA_stack(Stack): def top_minus(self, offset): """Returns an element of self, at a specified offset from the top. arguments: self -- an RA_stack offset -- a nonnegative integer; 0 indicates the top element""" assert offset >= 0 and offset < len(self.contents) tempList = [] position = 0 while position < offset: tempList.append(self.top()) self.pop() position += 1 result = self.top() for e in tempList: self.push(e) return result ra = RA_stack() for e in range(10): ra.push(e) for offset in range(5): print ra.top_minus(offset)