Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 18, 2020 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/e4845dc5473ba654c70ed12891dfcab9 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/e4845dc5473ba654c70ed12891dfcab9 to your computer and use it in GitHub Desktop.
from collections import deque
queue=deque([1,2,3])
#adds elements to the end of list
queue.append(4)
print (queue)#Output:deque([1, 2, 3, 4])
queue.append(5)
print (queue)#Output:deque([1, 2, 3, 4, 5])
#retrieves element from begining of list. (first in first out.)
print (queue.popleft())#Output:1
print (queue)#Output:deque([2, 3, 4, 5])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment