If we want to know how many times an object is present in list List.count feature is used.

b=[‘apple’, ‘orange’, ‘mango’, ‘guavava’, ‘apple’]

To count how many times apple present in list

b.count(‘apple’)

Output:2

count how many times an object appears using list.count
List.Count

It will raise value error when element does not present in list.

By SC

One thought on “List.count”

Leave a Reply

Your email address will not be published. Required fields are marked *