Python class implementing a stack using a list

This Python class implements a stack using a list. The stack supports the following operations: push, pop, size, and isEmpty.

Problem

Given a list of integers, write a Python class that implements a stack using a list. The stack should support the following operations:
push(x): Add an item x to the top of the stack.
pop(): Remove and return the top item from the stack.
size(): Return the number of items in the stack.
isEmpty(): Return true if the stack is empty, false otherwise.
Example input:
myStack = Stack()
myStack.push(1)
myStack.push(2)
myStack.push(3)
Example output:
3
2
1

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by kayakane
class Stack:
    def __init__(self):
        self.stack = []

    def push(self, x):
        self.stack.append(x)

    def pop(self):
        return self.stack.pop()

    def size(self):
        return len(self.stack)

    def isEmpty(self):
        return len(self.stack) == 0

myStack = Stack()
myStack.push(1)
myStack.push(2)
myStack.push(3)

print(myStack.pop())
print(myStack.pop())
print(myStack.pop())

A.I. Evaluation of the Solution

This solution is complete and solves the problem. The approach is straightforward and easy to understand.

Evaluated at: 2022-11-26 02:16:44