class myqueue(object): def __init__(self): self.stack=[] self.stack2=[] def push(self,values): for i in values: self.stack.append(i) def pop(self): while self.stack: self.stack2.append(self.stack.pop()) ret=[] while self.stack2: ret.append(self.stack2.pop()) return ret del ret a=myqueue() a.push([1,2,3,4,4]) print(a.pop())