python) implementing stack using python~!!
Hello~!
I'm lulu
Today I'm going to implement a stack using python.
Using python language to implement a stack, is a facile method.
Let's see how can we implement a stack using python.
In this way, we can implement a stack using python easily :-)
I'm lulu
Today I'm going to implement a stack using python.
Using python language to implement a stack, is a facile method.
Let's see how can we implement a stack using python.
class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return not self.items
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
if self.items:
return self.items[-1]
In this way, we can implement a stack using python easily :-)
If you have any questions or any opinions, tell me you'll be welcomed :-)
Thank you :-)
Comments
Post a Comment