DEV Community

Cover image for Data Structure in Python3: Stack
luthfisauqi17
luthfisauqi17

Posted on • Edited on

4 3

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:

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay