weakish weakish - 2 months ago 8
Python Question

How can I count the occurrences of a list item in Python?

Given an item, how can I count its occurrences in a list in Python?

Answer
>>> [1, 2, 3, 4, 1, 4, 1].count(1)
3