w3resource logo


Python Exercises

Python Exercise: Check whether an element exists within a tuple

Python tuple: Exercise-10 with Solution

Write a Python program to check whether an element exists within a tuple.

Sample Solution :-

Python Code :

>>> tuplex = ("w", 3, "r", "e", "s", "o", "u", "r", "c", "e")
>>> print("r" in tuplex)
>>> print(5 in tuplex)

Output:

>>>
True
False
>>>

Python Code Editor:

tuplex = ("w", 3, "r", "e", "s", "o", "u", "r", "c", "e")
print("r" in tuplex)
print(5 in tuplex)

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