w3resource logo
Python Exercises

Python Exercise: Repeated items of a tuple

Python tuple: Exercise-9 with Solution

Write a Python program to find the repeated items of a tuple.

Sample Solution:-

Python Code:

>>> #create a tuple
>>> tuplex = 2, 4, 5, 6, 2, 3, 4, 4, 7 
>>> print(tuplex)
>>> #return the number of times it appears in the tuple.
>>> count = tuplex.count(4)
>>> print(count)

Sample Output:

(2, 4, 5, 6, 2, 3, 4, 4, 7)                                                                                   
3   

Python Code Editor:

#create a tuple
tuplex = 2, 4, 5, 6, 2, 3, 4, 4, 7
print(tuplex)
#return the number of times it appears in the tuple.
count = tuplex.count(4)
print(count)

Improve this sample solution and post your code through Disqus