스택

#스택개념

#구조

#스택코드

#!/usr/bin/python
def push(item):
    stack.append(item)

def pop():
    return stack.pop()

if __name__ == '__main__':
    stack = []
    push(1)
    push(2)
    push(3)
    push(4)

    print("현재 stack의 모습")
    print(stack)

    while stack:
        print("POP > {}".format(pop()))

큐

#큐개념

#구조

#큐코드

#!/usr/bin/python
def put(item) :
    queue.append(item)

def get():
    return queue.pop()

if __name__ == '__main__':
    queue = [] # queue create
    put(1)
    put(2)
    put(3)
    put(4)
    print("현재 queue의 모습")
    print(queue)

    while queue:
        print("POP > {}".format(get()))