0% found this document useful (0 votes)
17 views2 pages

Python Stack Class Implementation

Uploaded by

Erdey Syoum
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Python Stack Class Implementation

Uploaded by

Erdey Syoum
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

class Stack:

def __init__(self):

[Link] = []

def is_empty(self):

return [Link] == []

def push(self, item):

[Link](item)

def pop(self):

return [Link]()

def peek(self):

return [Link][len([Link]) - 1]

def size(self):

return len([Link])

def display(self):

return [Link]

def reverse(self):

return [Link][:: -1]

stack1 = Stack()

[Link](87)

[Link](96)
[Link]('hello')

print('values', [Link]())

print('top element', [Link]())

print('is empty', stack1.is_empty())

print('size: ', [Link]())

print('pop', [Link]())

print('values after pop', [Link]())

print('in reverse', [Link]())

You might also like