Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Using Lists as Queues

>>> from collections import deque
>>> queue = deque(["Eric", "John", "Michael"])
>>> queue.append("Terry")           # Terry arrives
>>> queue.append("Graham")          # Graham arrives
>>> queue.popleft()                 # The first to arrive now leaves
'Eric'
>>> queue.popleft()                 # The second to arrive now leaves
'John'
>>> queue                           # Remaining queue in order of arrival
deque(['Michael', 'Terry', 'Graham'])
Comment

PREVIOUS NEXT
Code Example
Python :: rearrange columns pandas 
Python :: loop through list of lists jinja 
Python :: include in flask 
Python :: how to get more than one longest word in a list python 
Python :: python print string and variable 
Python :: stop flask server 
Python :: python request add header 
Python :: tensorflow evaluation metrics 
Python :: plot path in pillow python 
Python :: a list of keys and a list of values to a dictionary python 
Python :: CACHE_TYPE flask 
Python :: python google docs api how to get doc index 
Python :: requests sessions 
Python :: python string starts with any char of list 
Python :: Sum of Product 1 
Python :: python 2 print in same line 
Python :: chr() function in python 
Python :: How to Pass Additional Context into a Class Based View in django 
Python :: python windows os.listdir path usage 
Python :: django on delete set default 
Python :: lambda function if else in python 
Python :: binary search recursive python 
Python :: np.vectorize 
Python :: can a function output be save as a variable python 
Python :: iterating over tuples in python 
Python :: convert df.isnull().sum() to dataframe 
Python :: find if value exists in dictionary python 
Python :: values django 
Python :: python while loop guessing game 
Python :: python data type conversion 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =