Creating stack in given class

class stack:
def init(self):
self.data = [9,8,7,6,5]
def pop(self,index):
return self.data.pop(index)
def display(self):
print(self.data)
def peek(self):
return self.data[-1]

s = stack()
s.display()
print(s.pop(2))
s.display()
print(s.peek())

6 Likes

@anithasuthar2000

Well done.keep going

2 Likes