I had a problem where I was required to write a function where if x was less than lo the output would be lo and if x was greater than hi the output would be hi. Otherwise the output would be x. The solution to the problem was:
def hilo(lo, x, hi):
return min(max(x, lo), hi)
Can someone give me an explanation as to the order of the parentheses in the return statement? I tried writing like this:
return min(max(x, lo, hi))
but obviously, that didn't work.
minfunction with just 1 parameter (return value of themaxfunction). That doesn't make a sense (unless that parameter is iterable, which is not your case).