.count()
Takes in a list of values of any data type, and returns the number of times(count) a particular value is present within the list.
Syntax
list.count()
Example 1
Use .count()
to count the number of occurrences of the string "cat"
in the pets
list:
Example 2
Use .count()
to count the number of occurrences of the integer 3
in the treats_per_pet
list: