This bit of code is from hackerrank.com.
def pop(self):
#looks at the top of the queue
if len(self.stack2) > 0:
top = self.stack2.pop()
self.stack2.append(top)
Can someone please explain why it is popping off the last item in the stack/queue and then just appending it? I thought in queues, it is first in first out. In that case, the "top" item in the queue should be self.stack2.pop(0)
?