def to_tuple(x):
 if (not isinstance(x, (tuple, list))):
  return x
 return tuple(map(to_tuple, x))

def to_tuple ( x ) : if ( not isinstance ( x , ( tuple , list ) ) ) : return x return tuple ( map ( to_tuple , x ) )
converts lists to tuples .