list.count()
list.count() is a Python method in the List Methods category. Returns the number of occurrences of x in the list. The syntax is list.count(x). Parameters: x — value to count. Returns: Integer count. A typical example: lst = [1, 2, 2, 3]
lst.count(2) # 2
lst.count(4) # 0. A close sibling is list.append(), which appends an item to the end of the list. Modifies the list in place. A close sibling is list.extend(), which extends the list by appending all items from the iterable. A close sibling is list.insert(), which inserts an item at a given position. The first argument is the index. A close sibling is list.remove(), which removes the first occurrence of x from the list. Raises ValueError if not found. More about this category: List methods for sequence manipulation — append, sort, pop, extend, and more. For a broader walkthrough, read the List Methods guide.