class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return len(self.items) == 0
def push(self, item):
self.items.append(item)
def pop(self):
if self.is_empty():
raise IndexError("none stack")
return self.items.pop()
def peek(self):
if self.is_empty():
raise IndexError("none stack")
return self.items[-1]
stack = Stack()
stack.push(10)
stack.push(20)
stack.push(30)
print(stack.peek())
print(stack.pop())
print(stack.pop())
print(stack.is_empty())
print(stack.pop())
print(stack.is_empty())
To embed this project on your website, copy the following code and paste it into your website's HTML: