Method Name:
count
Method Signature:
count()
Parameters and return value:
None
Overview:
-
The count() method of tuple returns the number of times an element with a specific value occurs in a Python tuple.
-
The len() function is different. It provides the total number of elements present in the tuple.
Example:
# Example Python program that creates tokens = ("Ask", "not", "what", "your", "country", "can", token = "country"; token = "you"; |
Output:
Total number of tokens: 18 The token 'country' occured 2 number of times in the tuple The token 'you' occured 2 number of times in the tuple |