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)

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.



Join our Question Answer community to learn and share your programming knowledge.

Solve these problems:

Python: How to check whether a file exists using Python?

C#: Loops in c#

PHP: For each

SQL: JOIN using more than 5 tables

JavaScript: Blank Slide in Javascript Slideshow