Python solution of Stacks and Queues part