Rahul Jacob
Rahul Jacob

Reputation: 1

TypeError while trying to append an integer to a queue

I get an error while trying to append an integer to my queue.

from _collections import deque
q = deque
q.appendleft(5) 
q.appendleft(6)
q.appendleft(12)
print(q.pop())
print(q.pop())
print(q.pop())

I expected to get the values I appended in the reverse order but got a TypeError Instead.

TypeError: descriptor 'appendleft' for 'collections.deque' objects doesn't apply to a 'int' object

How else am I supposed to use a queue?

Upvotes: 0

Views: 824

Answers (1)

theoctober19th
theoctober19th

Reputation: 364

q = deque()

You missed the parentheses.

Upvotes: 3

Related Questions