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

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

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

Answers

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

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/2600191/how-can-i-count-the-occurrences-of-a-list-item-in-python

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils