educative.io

Possible Mistake!

Hi,

In the implementation of the dequeue function, I believe there’s a mistake.
Dequeue extracts the oldest element but in this line :
value = self.main_stack.pop() , pop() gets the newest element.

Also I printed self.main_stack using this line print(self.main_stack.stack_list)
at the beginning of the dequeue function and the result was the opposite of the example. The output was [5, 4, 3, 2, 1]. And that’s why the defined dequeue function shows the correct result. Simply because the initial stack is not created correctly and pop() in the dequeue function returns the last element which is 1. but the operation is not what dequeue should do

Thank you and I’m looking forward to your response.

`