Question

What will be the output of the following code when the pop method is executed? class Stack:     def __init__(self):         self.stack = []     def push(self, item):         self.stack.append(item)     def pop(self):         if not self.isEmpty():             return self.stack.pop()         else:             return "Stack is empty"     def isEmpty(self):         return len(self.stack) == 0 s = Stack() s.push(10) s.push(20) s.push(30) output = s.pop() print(output)

A 10
B 20
C 30
D Stack is empty
E None
Practice Next

Relevant for Exams:

Hey! Ask a query