Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Compare Functions by flpo
def checkio(f, g):
def h(*args, **kwargs):
status, out_f, out_g = '', None, None
try:
out_f = f(*args, **kwargs)
if out_f is None: raise ValueError
except:
status = 'f_error'
try:
out_g = g(*args, **kwargs)
if out_g is None: raise ValueError
except:
status = 'both_error' if status else 'g_error'
return out_f if out_f is not None else out_g,\
status if status else 'same' if out_f == out_g else 'different'
return h
July 10, 2017