python stack
-
StackBasic Programming/Data Structure 2018. 12. 11. 16:45
-- Python --class Stack(): def __init__(self): self.data = [] self.top = 0 #self.max = 100 def push(self, value): self.data.append(value) self.top += 1 def pop(self): if self.top is 0: print('Error. Stack is empty.') return self.top -= 1 data = self.data[self.top] del self.data[self.top] return data def peek(self): if self.top is 0: print('Error. Stack is empty') return return self.data[self.top..