Python Practice › Tuple Programs › Program 69
Is the value a tuple?
Write a Python program that returns True if a value is a tuple.
Input
(7, 4, 9, 2, 0), [7, 4]
Output
(7, 4, 9, 2, 0) True [7, 4] False
Approach
isinstance(x, tuple).
Solution
for value in [(7, 4, 9, 2, 0), [7, 4]]: print(value, isinstance(value, tuple))Output
(7, 4, 9, 2, 0) True [7, 4] False
Learn the concept
New to this topic? Read the lesson, then come back.