Created
September 11, 2022 16:08
-
-
Save ZhouYang1993/02cee2bc568073778dce2c73f17ca3ad to your computer and use it in GitHub Desktop.
Using deque in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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