Count function in Python

Count function is used to count the number of occurrences of given string / number. When the string is not found, count method returns 0. Count function takes one mandatory argument

cars = ["Mercedes Benz","Honda","Audi", "Volkswagen"]
cars.count('Audi')
cars.count('Tesla')

Output
1
0


Note : Unlike many other programming languages, count function does not give the number of items in a list it provides the number of times the value was preset in the list. To get the number of items in list use len function