Python Liste sayısı() Yöntem
Örnek
Listede "kiraz" değerinin kaç kez göründüğünü döndürün fruits
:
fruits = ['apple', 'banana', 'cherry']
x = fruits.count("cherry")
Tanım ve Kullanım
Yöntem count()
, belirtilen değere sahip öğelerin sayısını döndürür.
Sözdizimi
list.count(value)
Parametre Değerleri
Parameter | Description |
---|---|
value | Required. Any type (string, number, list, tuple, etc.). The value to search for. |
Daha fazla örnek
Örnek
Listede 9 değerinin kaç kez göründüğünü döndürün:
points = [1, 4, 2, 9, 7, 8, 9, 3, 1]
x = points.count(9)