Counts the number of occurrences of item 30 from a tuple


The program is written in Python and it counts the number of occurrences of an element in a tuple. The program creates a tuple t containing 7 elements (30, 50, 10, 30, 70, 50, 30). The program then uses the count() method on the tuple t to count the number of occurrences of the value 30 in the tuple. The result is then printed using the print() function.

Source Code

t = (30, 50, 10, 30, 70, 50, 30)
print("Number of Counts 30 :",t.count(30))
 

Output

Number of Counts 30 : 3


Example Programs