• Min and Max problem

 

I would like to give some feedback about ...

From: https://py.checkio.org/mission/min-max/solve/

HTTP_USER_AGENT:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50

When running this on my local PyCharm (using Python 3.5), the code below provides the correct result when processing the following assertion: assert max(2.2, 5.6, 5.9, key=int) == 5.6, "Two maximal items"

However, when I run it inside the CheckIO environment (using Python 3.6, it returns an incorrect result. I am not sure how to resolve this.

def max(*args, key=None, **kwargs):
    mkey = key
    if len(args) == 1:
        lstArgs = list(args[0])
    else:
        lstArgs = list(args)
    lstArgs = sorted(lstArgs, key=mkey, reverse=True)
    result = lstArgs[0]
    return result

Any guidance is appreciated.

---Andrew