What the diffrent?

from collections import deque
que = deque()
que.append('first')
que.append('second')
que.append('last')
print(que)
print(que.popleft())
print(que.popleft())
print(que.popleft())

first

# and this
que1 = deque()
que1.appendleft('first')
que1.appendleft('second')
que1.appendleft('last')
print(que1)
print(que1.popleft())
print(que1.popleft())
print(que1.popleft())

second

So appendleft seems to mean that it puts it at the 0 position and pushes everything down. Go read the docs on that appendleft vs. append.

1 Like