Python Practice › Tuple Programs › Program 69

Is the value a tuple?

EasyTuple Programs · 69 of 70

Write a Python program that returns True if a value is a tuple.

Advertisement
Input
(7, 4, 9, 2, 0), [7, 4]
Output
(7, 4, 9, 2, 0) True
[7, 4] False

Approach

  1. isinstance(x, tuple).

Solution

Python
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
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More tuple programs

← All 70 Tuple Programs