I tried to implement a queue using 2 stacks using the code below.
Utility Stack implementation.
class Stack():
    def __init__(self,array = []):
        self.array = array
    def is_empty(self):
        return self.array == []
    def pop(self):
        if self.array == []:
            raise Exception('stack is empty')
        else:
            popped_element = self.array.pop()
            return popped_element
    def push(self,key):
        self.array.append(key)
    def top(self):
        return self.array[-1]
    def __repr__(self):
        return " ".join(list(map(str,self.array)))
if __name__ == "__main__":
    q = Stack()
    q.push(1)
    q.push(2)
    q.push(3)
    q.push(4)
    q.push(5)
    print(q.pop())
    print(q.pop())
    print(q.pop())
    q.push(10)
    print(q)
from stack import Stack
class TwoStackQueue1():
    def __init__(self):
        self.stack1 = Stack()
        self.stack2 = Stack()
    def enqueue(self,key):
        self.stack1.push(key)
    def dequeue(self):
        while(self.stack1.is_empty() != True):
            top = self.stack1.top()
            print("eval_dequeue",top)
            self.stack2.push(top)
            self.stack1.pop()
        if self.stack2.is_empty() == True:
            raise Exception("Queue is empty")
        else:
            top = self.stack2.pop()
            return top
    def is_empty():
        return self.stack1.is_empty() and self.stack2.is_empty()
if __name__ == "__main__":
    q = TwoStackQueue1()
    q.enqueue(1)
    q.enqueue(2)
    q.enqueue(3)
    q.enqueue(4)
    q.enqueue(5)
    print(q.stack1)
    print(q.dequeue())
when i tried to perform above operations on the queue , my code is getting stuck in infinite recursion because pop operation of my stack is not working . Can someone please help me figure out why my code (Queue operations:- q.dequeue()) is getting stuck in infinite recursion? Thanks.