DEV Community

Arunkumar Dharuman
Arunkumar Dharuman

Posted on

fixed length queue

To create a fixed length queue and to discard old values as you and new values

from collections import deque dq = deque(maxlen=5) for i in range(10): dq.append(i) print(dq) 
Enter fullscreen mode Exit fullscreen mode

Output:
deque([5, 6, 7, 8, 9], maxlen=5)

Top comments (0)