Your methods -- both of them -- don't return anything. What I would do to sort this is:
class Stack:
def __init__(self):
self.stack = []
def pushit(self, item):
if len(self.stack) == 9:
print("Stack is full: " + self.stack)
return None
else:
print(self.stack.push(self.item))
return self.item
def popit(self):
if self.stack == []:
print("Stack underflow: " + self.stack)
return None
else:
ret = self.stack.pop()
print(ret)
return ret
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…