Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Created September 11, 2022 16:08
Show Gist options
  • Save ZhouYang1993/02cee2bc568073778dce2c73f17ca3ad to your computer and use it in GitHub Desktop.
Save ZhouYang1993/02cee2bc568073778dce2c73f17ca3ad to your computer and use it in GitHub Desktop.
Using deque in Python
from collections import deque
dq1=deque([1,2,3,4,5])
print(dq1)
# deque([1, 2, 3, 4, 5])
dq2=deque('abcde')
print(dq2)
# deque(['a', 'b', 'c', 'd', 'e'])
dq3=deque([i for i in range(10) if i%2==0])
print(dq3)
# deque([0, 2, 4, 6, 8])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment