Trying to put the 4 queue.enqueue into a while loop.
Any suggestions? Files are attached.

from string13 import *
from queue import *


stack1 = Stack()
queue = Queue()
pallist =[]
pallist2 =[]
def main():
    stack1.push(4)
    stack1.push('2')
    stack1.push(1)
    stack1.push(5)

    while not stack1.isEmpty():
        pallist.append(stack1.pop())
    print pallist

    
    """while queue.size < len(pallist):"""
    queue.enqueue(pallist[3])
    queue.enqueue(pallist[2])
    queue.enqueue(pallist[1])
    queue.enqueue(pallist[0])

    while not queue.isEmpty():
        pallist2.append(queue.dequeue())
    
    stack1.push(pallist2)
    
    print stack1.pop()
    
main()
>>> range(3,-1,-1)
[3, 2, 1, 0]

Also, consider using the collections.deque class for stacks and queues.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.