Suppose,
var = ('x', 3)
Run Code Online (Sandbox Code Playgroud)
How to check if a variable is a tuple with only two elements, first being a type str and the other a type int in python? Can we do this using only one check? I want to avoid this -
if isinstance(var, tuple):
if isinstance (var[0], str) and (var[1], int):
return True
return False
Run Code Online (Sandbox Code Playgroud)