Count the number of occurrences of an element in a list in Python Python tip: You can count occurrences of an element in a list with .count(). For example: users = ["Jan", "Mike", "Marry", "Mike"] print(users.count("Mike")) # => 2
Python tip:
You can count occurrences of an element in a list with .count().
.count()
For example:
users = ["Jan", "Mike", "Marry", "Mike"] print(users.count("Mike")) # => 2