The count Method in Python: Counting Values in a List

Returns the number of occurrences of a value in a list.

count(x)

  • x -- value to count occurrences of.
random_list = [4, 1, 5, 4, 10, 4]
random_list.count(4)  # 3