Data Structure in Python3: Stack

luthfisauqi17

luthfisauqi17

Posted on November 10, 2021

Data Structure in Python3: Stack
class Stack:
    def __init__(self):
        self.arr = []

    def pop(self):
        data = self.arr.pop()
        return data

    def push(self, data):
        self.arr.append(data)

    def peek(self):
        return self.arr[len(self.arr)-1]

    def isEmpty(self):
        return len(self.arr) == 0
Enter fullscreen mode Exit fullscreen mode

Sources and Images:

πŸ’– πŸ’ͺ πŸ™… 🚩
luthfisauqi17
luthfisauqi17

Posted on November 10, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related