In [1]:
def print_len_lbyl_list(x):
if isinstance(x, list):
print(len(x))
else:
print('x is not list')
In [2]:
print_len_lbyl_list([0, 1, 2])
In [3]:
print_len_lbyl_list(100)
In [4]:
print_len_lbyl_list((0, 1, 2))
In [5]:
print_len_lbyl_list('abc')
In [6]:
def print_len_lbyl_list_tuple(x):
if isinstance(x, (list, tuple)):
print(len(x))
else:
print('x is not list or tuple')
In [7]:
print_len_lbyl_list_tuple([0, 1, 2])
In [8]:
print_len_lbyl_list_tuple(100)
In [9]:
print_len_lbyl_list_tuple((0, 1, 2))
In [10]:
print_len_lbyl_list_tuple('abc')