Q:

Write a Python program to count the number of times a specific element presents in a deque object.

0

Write a Python program to count the number of times a specific element presents in a deque object.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import collections
nums = (2,9,0,8,2,4,0,9,2,4,8,2,0,4,2,3,4,0)
nums_dq = collections.deque(nums)
print("Number of 2 in the sequence")
print(nums_dq.count(2))
print("Number of 4 in the sequence")
print(nums_dq.count(4))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now