Fitre de pile dans Python

"""
Stack is a Last In First Out Data structure
It can be implemented using a list as illustrated belo
push <==> append, and pop <==> pop from list
"""
stack = ["John", "Elie", "Rami"]
# Push an item
stack.append("Wissam")
print(stack)

# Pop an item: removes the last item
print(stack.pop())

"""
Queue is a First In First Out Data structure
It can be implemented efficiently using a Deque
enqueue <==> append and dequeue <==> popleft
"""
from collections import deque
queue = deque(["Wissam", "John", "Elie"])
queue.append("Rami")
print(queue)

# popleft removes the first element in queue
print(queue.popleft())
Wissam