To count the number of occurrences of an item in a Tuple, just use the count()
method.
car_brands = ('ferrari', 'bmw', 'mclaren', 'bmw', 'bmw', 'ferrari')
print(car_brands.count('bmw'))
print(car_brands.count('ferrari'))
3
2
To count the number of occurrences of an item in a Tuple, just use the count()
method.
car_brands = ('ferrari', 'bmw', 'mclaren', 'bmw', 'bmw', 'ferrari')
print(car_brands.count('bmw'))
print(car_brands.count('ferrari'))
3
2