As per another answer,
Stack is not built-in type in Python.
So, It has to define as there is not any library stated in interactive python tutorial.
I have taken Stack() class from interactive python tutorial and your code should be like this
class Stack:
def __init__(self):
self.items = []
# I have changed method name isEmpty to is_empty
# because in your code you have used is_empty
def is_empty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[len(self.items)-1]
def size(self):
return len(self.items)
s = Stack()
s.push('a')
print(s.is_empty())
print(s.peek())
print(s.is_empty())
print(s.pop())
print(s.is_empty())
Output:
False
a
False
a
True
Stackfrom whatever module it is defined in.